Spring boot WAR deployment to tomcat - spring-boot

I have recently started packaging my application as a war.
I have noticed whenever I deploy the application within tomcat, 404 errors are now placed into tags, where as when deploying as a standalone, the _body response would be in JSON. Does anyone know why this is happening?
Within the tomcat on a war deployment I get the return _body:
<.!doctype html><.html lang="en"><.head><.title>HTTP Status 404 – Not Found<./title>
On a standalone deployment the return _body =
"{"timestamp":"2018-06-26T18:28:38.731+0000","message":"04ed1a7a-729d-48d7-b306-8e9ff6d7a2e0","details":"uri=/api/userSecurity/login","status":4011003}"
Is there maybe some sort of tomcat setting that is causing this?
Thank you

The user solved the problem by preparing the application with bootstrap to be deployed in tomcat as explained here.

Related

Spring boot war with external tomcat setting context path

Iam working on a spring boot application, we are using war packaging. When i run the application in my local machine with bootRun or in STS,it is working as expected, but when i deploy it in PCF, the context path is not applying. After some research i came to know that server.servlet.context-path will not work in external tomcat, so i added context.xml with
in webapp/META-INF, but it is still not working. The API /test is working but it is supposed to be /myPath/test. I spent lot of time on research haven't found a working solution. Can anyone help. Thanks.

Getting Problem in apache server while deploying spring boot application on tomcat 9: Status 404 - Not Found

enter image description hereI have developed application that is build in spring boot which is working fine in my local but while deploying on production i'm getting error.
HTTP Status 404 - Not Found
Description: The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
Check your tomcat health
Remove your war and start it
Go to localhost:port and a tomcat home page must be renderized:
If your tomcat does not show the expected home page, try to fix it before to deploy your app.
Possible cause
According to your comments, you issue could be this:
You java web app shows the home page in your localhost (eclipse) at:
http://localhost:8080
But when you deploy in a tomcat, you are using a war file which is deployed in webapps folder. For example:
acme-web.war
So if you deploy this war in your tomcat hosted in
http://localhost:1234 (which must render the tomcat home page)
Your app will be available at:
http://localhost:1234/acme-web
There is a technique to show your web instead the tomcat home page. Just ask me!
I hope this helps you.

Netbeans 8.2. Maven webapplication won't run on Tomcat but will on Glasfish server

I am developing a simple restful server and want to deploy it on a Tomcat server. When I deploy the project it won't run and gives me the message: http 404, The requested resource is not available.
The project is a default, newly created Maven project and when I select Glasfish it runs fine. Can anyone give help me to find out what I am doing wrong?
I found the problem myself. For anyone struggling. Java Jax-RS doesn't run default on Tomcat. You need Tomcat EE or add EE to Tomcat.

How to create deployable springboot war

I am trying to create a maven spring boot application to be deployed in Tomcat. I am following what is suggested in Spring docs and other stackoverflow suggestions- war, Application.java extending SpringBootServletInitializer, removing spring-boot-maven-plugin from build plugins etc. War file is generated and is deployed in tomcat. But what I found is all static files are packaged under /WEB-INF/classes folder and I am not able to access the page. My project structure is as below:
Can anybody tell me how I can package the war properly to be deployed in Tomcat.
That doesn't change anything.
If you put your static assets in src/main/resources/static (and they end up in WEB-INF/classes/static), Spring Boot will serve them properly. So a src/main/resources/static/foo.png will be available at http://localhost:8080/your-context/foo.png if the context of your webapp is your-context.
Regarding the configuration, you can also go on start.spring.io, click advanced and chose war and you'll get an empty project pre-configured.
Or you can click this: https://start.spring.io/#!packaging=war
The issue is because of version issue. I compiled the application with Java 8 and deployed it in tomcat running under JRE 7. It may help someone facing the same issue.
I got the clue from the below post:
Spring boot war file deploy on Tomcat.

Deploy spring app in Websphere get Error 404: SRVE0190E

I'm trying to deploy a spring + angularJS app (packaging as war) into websphere (7.0.0.25), but even for the sample app I cloned from spring, I always get Error 404: SRVE0190E: File not found. And even for the spring app, I have to explicitly specify index.html in the URL, otherwise I get the same error. But the angular side is tolerable, can anyone help me with the spring side?
The sample application is: https://github.com/spring-guides/gs-convert-jar-to-war-maven.git
After doing "mvn clean package" in "/gs-convert-jar-to-war-maven/complete" to get the war, I follow the steps here to upload and deploy the war in websphere:
http://www.packtpub.com/article/deploying-applications-on-websphere-application-server-7.0-part1
I also tried this post to set the custom properties but still didn't work: http://frightanic.com/software-development/solution-to-error-404-srve0190e-on-websphere-6-1/
Also, both my app and the sample spring app don't have a web.xml as spring will take care of it. Both apps work fine in jetty and Tomcat. Only websphere has the problem. Besides, I don't know how to manually configure a web.xml if that will be the solution (need to be pointed to more resources).
The URLs I tried but failed to access the app are:
localhost:9080
localhost:9080/gs-convert-jar-to-war-0_1_0_war
localhost:9080/someAppName
Thanks in advance!
It turns out that websphere 7 doesn't support some spring annotations/classes. My solution is to write a web.xml file and turn off spring auto-configuration.

Resources