Avatar billede fredand Forsker
06. august 2022 - 14:48 Der er 3 kommentarer og
1 løsning

My react-app does not render

Hello,
My react-app does not render in the browser when I access it from an app server, so I hope to get some help with it.

Below is the info I hope is needed to understand the structure.

I run a weblogic server 14.1
I deploy a ear with several war-files
Inside the ear I got a angular-app and a react-app in individual war-files.
I build the wars and the ear with maven.
For the ear I add the wars like:
                        <webModule>
                            <groupId>weblogic-ejb-project</groupId>
                            <artifactId>weblogic-angular-client</artifactId>
                            <bundleFileName>weblogic-angular-client.war</bundleFileName>
                            <contextRoot>angular</contextRoot>
                        </webModule>
                        <webModule>
                            <groupId>weblogic-ejb-project</groupId>
                            <artifactId>weblogic-react-client</artifactId>
                            <bundleFileName>weblogic-react-client.war</bundleFileName>
                            <contextRoot>react</contextRoot>
                        </webModule>


The angular-app renders when I access it from the browser (http://127.0.1.1:7001/weblogic-angular-client/)
But not the react-app (http://127.0.1.1:7001/weblogic-react-client/), just a blank page. How ever the view-source shows the content from index.html like:

<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>React App</title><script defer="defer" src="/static/js/main.a083f8ba.js"></script><link href="/static/css/main.073c9b0a.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>

...so it looks like the react-app is present with the content from index.html

Do you guys see anything missing for the react-app?

Best regards
Fredrik

PS1 it does render if i run npm start and access it from localhost:3000, so it does work that way.
PS2 I have also checked that main.a083f8ba.js is in the correct folder and can be accessed from http://127.0.1.1:7001/weblogic-react-client/static/js/main.a083f8ba.js
PS3 I have tried with the same result from Firefox, Chromium on Linux and Chrome from an old Android-phone

A picture of the ear and the war files might be found here:
https://pasteboard.co/ILitJ3ykxbqm.png
Avatar billede fredand Forsker
06. august 2022 - 15:31 #1
Hmm I see a message in the console: Loading failed for the <script> with source “http://127.0.1.1:7001/static/js/main.a083f8ba.js”.
Avatar billede fredand Forsker
06. august 2022 - 19:37 #2
looks like this solved it in my package.json
{
  "name": "react-client",
  "version": "0.1.0",
  "private": true,
  "homepage": "/weblogic-react-client",
Avatar billede fredand Forsker
06. august 2022 - 19:39 #3
npm start also takes me to http://localhost:3000/weblogic-react-client ....nice!
Avatar billede erikjacobsen Ekspert
07. august 2022 - 09:06 #4
I read it as you solved it yourself. If so you should mark #2 as an answer.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester