CrazyMac
CrazyMac

Reputation: 462

Spring boot deployed on Tomcat 8 having structure or application context issues

I have a simple spring boot application which I am able to run in my local with the url http://localhost:8080/#/appName. This is my application structure

enter image description here

When I package this as a war and try to deploy this in the linux server, I am not able to load the application with the same context ( http://SERVERNAME:PORT/#/appName) that I was able to load in my local. I think I am missing something, can someone guide me.

Here is the application structure after deployed in the tomcat server.

enter image description here

Under the WEB-INF/classes/ directory, the content is as below.

enter image description here

Upvotes: 0

Views: 565

Answers (1)

ameenhere
ameenhere

Reputation: 2353

Spring boot when deployed into a tomcat container will have its context root as its war name by default. Lets say you have tomcat installation at "localhost" on port 8080. You deploy the war named "abc.war", which means you drop it into the webapps directory. The app gets deployed with the main folder being "abc" and other folders (WEB-INF,META-INF,etc) within it. You context root of that particular application will now be

http://localhost:8080/abc

If your application has an endpoint path as "cde/fg", then with the context root added to this path, the entire url will be

http://localhost:8080/abc/cde/fg

But, if you are running the exact same spring boot app in an embedded container running on "localhost" on port 8080, (and assuming the application.properties did not mention a server.context-path in it), then the above end point in the embedded container will be

http://localhost:8080/cde/fg

The application is then deployed in the root context of the container.

I assume this subtle difference is what you are missing. If my guess is right, after you deploy in the tomcat container simply add the war name to the url like this -

http://SERVERNAME:PORT/{warname}/#/appName

Upvotes: 2

Related Questions