Spring Boot App works fine on IntelliJ but not in tomcat - spring

I'm trying to deploy a Spring project (war format) in Tomcat. The project (https://github.com/iku747/DemoTec2) works fine in IntelliJ. However when i try to run war in Tomcat it only loads the first .jsp (login.jsp) and then if i try to do anything it said error404 resource not found.
I dont know what's happening, can anyone help me?
Information:
The project uses Spring MVC + spring boot + spring security + maven
Tomcat version: 8.5.23
Any other information about versions etc can be found on the github.
Thank you very much.

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.

Spring boot security is not working after deploying war file into external tomcat

I have defined tomcat dependency as mentioned below.
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
When I am running locally everything is working fine. So it is working fine only in embedded tomcat but not in external tomcat.
Frontend app is developed using Angular 7. Frontend build files are placed inside static folder in spring boot application.
Problem that I am facing is, Rest API's are not secured when it is deployed in external Apache tomcat.
Any help is appreciated.

Do we really need to add spring boot starter web for spring boot admin clients?

Version 1.5.4 was working fine without extra declaration of starter web in POM of Spring Boot Admin Clients. When I upgraded to 2.0.1, I had to add starter web to POM to make it work. Without starter web in client apps, there is no error or no log related to registering the application.
It's not documented anywhere as far as I know. Can anyone please confirm?
Spring Boot Admin 2.x can run on netty and on tomcat. So if you want to run on tomcat you have to explicitly import the spring-boot-starter-web.
The getting started guide contains this dependency http://codecentric.github.io/spring-boot-admin/current/#set-up-admin-server

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.

Spring Boot 1.2.4.RELEASE cannot generate a simple Startup Project

I am using Spring Boot version 1.2.4.RELEASE to generate a simple web project. The full Url for creating this project is:
http://start.spring.io/starter.zip?name=demo3&groupId=org.test&artifactId=demo3&version=0.0.1-SNAPSHOT&description=Demo+project+for+Spring+Boot&packageName=demo3&type=maven-project&packaging=jar&javaVersion=1.7&language=java&bootVersion=1.2.4.RELEASE&dependencies=web
The download starter project opened in the STS 3.6.4.RELEASE with tons of errors: Missing artifact, ArtifactDescriptorException from the pom.xml file.
However, if I use version 1.1.12.RELEASE of the Spring Boot, I have no problem to create the startup project.
Is this a bug in the 1.2.4.RELEASE of the Spring Boot? I doubt it.
The project is OK.
Please to check your local env, specially connexion, maven configuration (setting.xml), ...etc
Good luck

Resources