Search code examples
reactjsjboss

ReactJS Build WAR File Not Displaying React Components On JBOSS Web Server


I have a ReactJS frontend web application which I have built for production using "npm run build"

The ReactJS frontend web app needs to be hosted on a JBOSS Web Server (JWS) - so I created a WAR file from the above React build in Eclipse by creating a Dynamic Web Project and using m2e and the build was successful.

I deployed the WAR file to the JBOSS JWS server and after starting up JBOSS and accessing the deployed startup page, the startup page was created properly with the Windows title properly displayed (I compared this by running the same React app locally on my laptop on localhost)

HOWEVER, the UI or page content or Rect components (the generated HTML which React generated from Javascript) was blank. It seems although the page was created properly, React was unable to convert the Javascript files to React components on the index.html page under .

enter image description here FIG 1 - Default opening webpage (blank) from WAR file on JBOSS JWS server

enter image description here FIG 2 - Default opening webpage (ReactJS components displayed) on local laptop (localhost, npm start)

enter image description here FIG 3 - WAR file structure

enter image description here FIG 4 - index.html and directory structure

enter image description here FIG 5 - package.json

I don't think there's anything wrong with my WAR directory structure or index.html as the index.html screen is showing the Window title correctly as in the localhost version - it's just that the React components (the HTML generated by React when it converts the Javascript) aren't being displayed despite there being a tags. If anyone knows of any solutions, please help thank you in advance.

Environment details: OS - RHEL 8.8 APP - JWS 5.7 JAVA - Openjdk 1.8.0_332.


Solution

  • I found out that in my pom.xml I had to set the environmental variable PUBLIC_IP path location to the server IP path which I hadn't and it still pointed to localhost. And also the src tag in my index.html file. When I changed these, it works!