Sprinboot deploying help needed?

Acid0

Executive Member
Joined
Feb 10, 2009
Messages
5,889
Reaction score
2,734
Location
Johannesburg
Hi there

I need some help from the people that works with Springboot and deploying their apps on tomcat 9.

IDE: IntelliJ Ultimate edition
IDE JDK : was 8 then changed to 10 then to 14 same results
Springboot 2.3.1
JVM: 10
Tomcat : v9

My Application works perfectly when running from the compiler.
Springboot starts, my internal tomcat starts and I am able to make requests from POSTMAN.

I can do a simple tomcat request with their default service example like http:localhost:8081/docs and get a response back
Once I create a WAR file and deploy it to tomcat server and try to do a request I get the following response back from Postman

The request is a simple GET to "http://localhost:8081/users" as a test
Code:
<body>
    <h1>HTTP Status 404 – Not Found</h1>
    <hr class="line" />
    <p><b>Type</b> Status Report</p>
    <p><b>Message</b> The requested resource [&#47;users] is not available</p>
    <p><b>Description</b> The origin server did not find a current representation for the target resource or is not
        willing to disclose that one exists.</p>
    <hr class="line" />
    <h3>Apache Tomcat/9.0.35</h3>
</body>

Can anybody shed some light on what I can try to fix this issue.
Regards
 
Hi there

I need some help from the people that works with Springboot and deploying their apps on tomcat 9.

IDE: IntelliJ Ultimate edition
IDE JDK : was 8 then changed to 10 then to 14 same results
Springboot 2.3.1
JVM: 10
Tomcat : v9

My Application works perfectly when running from the compiler.
Springboot starts, my internal tomcat starts and I am able to make requests from POSTMAN.

I can do a simple tomcat request with their default service example like http:localhost:8081/docs and get a response back
Once I create a WAR file and deploy it to tomcat server and try to do a request I get the following response back from Postman

The request is a simple GET to "http://localhost:8081/users" as a test
Code:
<body>
    <h1>HTTP Status 404 – Not Found</h1>
    <hr class="line" />
    <p><b>Type</b> Status Report</p>
    <p><b>Message</b> The requested resource [&#47;users] is not available</p>
    <p><b>Description</b> The origin server did not find a current representation for the target resource or is not
        willing to disclose that one exists.</p>
    <hr class="line" />
    <h3>Apache Tomcat/9.0.35</h3>
</body>

Can anybody shed some light on what I can try to fix this issue.
Regards
My assumption is that the context path when deployed on Tomcat is different. Check the tomcat logs and you'll find out what the context path is.
 
My assumption is that the context path when deployed on Tomcat is different. Check the tomcat logs and you'll find out what the context path is.
Yeah I found the issue.

That is exactly the issue I have stipulated in the project what my context path should be but tomcat takes the path that the war file is named and uses that as the path.... I am still learning :) so stupid faults will be made.

Will tomcat always take the war file name as a the path name or can you override it with something you need?
 
Yeah I found the issue.

That is exactly the issue I have stipulated in the project what my context path should be but tomcat takes the path that the war file is named and uses that as the path.... I am still learning :) so stupid faults will be made.

Will tomcat always take the war file name as a the path name or can you override it with something you need?
I haven't worked with tomcat in ages but there was ways to modify the context path and also to default it to root. You can google it or search through the docs and you will find out how it's done.

Out of curiosity, considering you are using Spring Boot, why are you even using tomcat when you can use the embedded one (IIRC, I think it has Tomcat and Jetty as well)? That's the beauty of Spring Boot. Use it the way they designed it. The other ways means tinkering the app servers you are going to use
 
I used NGINX tro accomplish this within about 30 minutes (after learning about NGINX for about 15 minutes)
 
I used to work mainly with Java and Spring Boot but have since switched over to NodeJs. In my experience, setting up and deploying to Tomcat was sooooo much more difficult than installing and deploying to nodejs. For smaller projects, maybe give node a try (if you're comfortable with js). Just my 2 cents
 
Top
Sign up to the MyBroadband newsletter
X