Tomcat started on port(s): 8080 but getting 404 - spring-boot

I am trying to run a simple spring-boot application but every time I am getting 404. Even with the simple setting and no code.
any clue what am I missing to run this application?

That's the expected outcome. The 404 is a real HTTP response from your Tomcat server. As you are starting an empty Spring Boot project, there's nothing to serve and the "Whitelabel Error Page" is the default Spring Boot 404 page.
To understand the difference when your Spring Boot application is not running, stop the Spring Boot application and then revisit http://localhost:8080.
You can now follow this Spring Boot guide and add your own endpoints to your project.

Rieckpil is correct by saying TOMCAT is giving you the 404 reply and therefore running. However, if you stop/start tomcat then the normal page will load from there on.
Thanks!

Related

Embedded tomcat in spring application

Hi, I am trying implement embedded tomcat server in spring application but problem is, it shows warning line no global web.xml and server was not started. Kindly help if someone face this same problem and overcome it

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

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

Spring Reactive WebSocket does not come up when spring-web is present

I have an existing spring web application that uses spring-boot-starter-web; I have been planning to introduce reactive into this application. For a new feature that I am working, I have pulled in spring reactive web socket, configured and coded as specified in the spring doc; but unfortunately it does not work (got 404).
I tried a sample application and that works perfectly.
I used this one as my sample application.
I found that the sample application comes up on Netty, not on Tomcat. So I added spring-boot-starter-web to it, got the server to start in Tomcat and got the same 404 as I got in my application.
I also added TomcatRequestUpgradeStrategy unsuccessfully.
should I assume that spring-web and spring-webflux conflict with each other and I should go back to the regular websocket? Please advise.
Spring said that if both spring web and spring webflux present in the classpath; spring web kicks in and reactive websocket won't come up.
More details here: https://github.com/spring-projects/spring-boot/issues/23236

Fail to deploy my spring boot application to asw beanwalk

I developed a spring boot project on Intellij, which is only backend for now. and wanna deploy it to aws.
I followed below
https://developer.okta.com/blog/2019/08/07/deploy-a-spring-boot-app-with-aws-elastic-beanstalk
Like he said ,I also get 502 error at first, then I did add server_port 5000 according to him
but I still get 502 bad gateway
http://personalprojectmanagement-env.eba-xzze9hnr.us-east-2.elasticbeanstalk.com/ is my website
anyone can help?
Thanks

Auto reload spring boot application in docker when using spring-security

I am developing an application with spring boot 2.
I deployed the application in docker, and I activated the "auto reload in docker with spring devtools"
but after adding spring-security, the autoreload does not work anymore.
I'm getting an error when the auto restart is triggered:
Exception in thread "File Watcher" java.lang.IllegalStateException: Unexpected 302 FOUND response uploading class files
Spring security is likely intercepting the HTTP requests that the autoreload system is using and redirecting you to the login page. You'll need to figure out what URLs the system uses and set those to permitAll() in the development environment.

Resources