SpringBoot Rest API: Works as Java Application, fails when deployed on tomcat - spring-boot

I have a Springboot project and it has a api which I can invoke from postman.
When I run the application using Main Class I'm able to hit the endpoint and get response.
But if I deploy it on tomcat using war of project the same endpoint says 404!
What am I missing?

There can be multiple possibilities
You didn't extended your application class to SpringBootServletInitializer. In this case, spring boot application will not be deployed to tomcat. To fix this add "extends SpringBootServletInitializer" to your main application class
You are hitting wrong url. Make sure you append your aplication name to url. Example - if http://localhost:8080/data works in your local, and your application name is app, you have to hit http://{{serverip:port}}/app/data when deployed
There is something wrong in application properties like DB configured is local and not accessible from tomcat etc. To check such issues, check your tomcat log file (/{{tomcat dir}}/logs/catalina.out

Related

jpa spring boot project not working external tomcat 9

I am trying deploy and run (Spring data) in external tomcat server. Deployment happening without any errors but getting 404 errors when I am trying to hit rest end point. The same rest working fine with out jpa changes. Do we required any data source configuration in external tomcat server in order to run the application. Please provide any reference for the same.

How to run a Spring Boot Application in a real online website instead of localhost:8080

I've created an application with the spring boot framework.
Everything runs fine on the localhost:8080.
Now I want to be able to run the application from my website.
So people can log in to the app and use the application from anywhere over the internet.
What should I do to manage this?

Aws Spring boot application view issue with jar and rest service issue with war

I would like to host one application on AWS elastic beanstalk(java). The application has one view and one rest service. First I uploaded the jar file and tried accessing, the path to view was giving me whitelabel error on AWS but it is working fine locally. Also, am able to access the rest service with jar.
After surfing the net, I created a war and uploaded on AWS(tomcat). Now, the view is working fine but I notice the path of rest service is returning 404. Can someone suggest what should I check or do?

Google app engine flexible not load context path of Spring boot application

I have spring boot application and already deploy on GAE Flexible env.
In my application, I already set my application context path in application.properties file look like:
server.context-path=/myapp
And it work fine on tomcat and jetty embedded server.
But when I deploy to GAE flex env my application not work with context path that I already set on my application.properties file.
It auto use context path "/" in GAE domain.
Because I'm using dispatch to defined routing on GAE with multi microservice, so I have to define a specify context path for each service.
Anybody can help me in this case?
Thanks.

How to deploy html from tomcat server with Springboot

So, the answer is probably super easy, but I just can't seem to figure it out.
I have set up a REST webservice, according to this tutorial: https://spring.io/guides/gs/rest-service/ and have set up the Requestmapping and everything using postman, and that end is working like I intended to.
I am setting up my site locally, but when I try to send a get request with jquery, I am receiving the following error: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
So I have understood that the problem is that I am trying to run my html from file:// and that the solution is to run it from localhost on the tomcat server and found this answer in another topic: Deploying just HTML, CSS webpage to Tomcat
However, I cannot find such a webapps folder, and I am assuming it is because my tomcat server is deployed using maven and springboot. So how do I deploy my html/js on the tomcat server when it is deployed this way?
I am working on a mac and with IntelliJ.
In your spring boot application you can put your index.html file in src/main/resources/static directory and it will be served by the application.
Also you may try to configure CORS in spring boot, see this answer for links.
If you are deploying normal web applications like jee apps you do it by placing your war file in webapps folder. The web apps folder is inside your tomcat
But for for intellij-idea go through this, it should work:
Where is my app placed when deploying to Tomcat?

Resources