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

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.

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 App works fine on IntelliJ but not in tomcat

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.

Spring Boot with maven war dependancy

I have Spring Boot web project with dependency to maven overlay war file which is also Spring web project. War is included in pom.xml.
How can I deploy that war along with Spring Boot application so I can use rest endpoints that belong to war file. I'm trying to start application from STS simply by running it as Java application. While application is starting, I can see only URLs that belong to Spring Boot project, but URLs that belong to war file are missing.
I believe Spring boot does not support that. See issue here
Try building a war and deploying it into a container.

Springboot finds files in src/main/webapp but not src/main/webapp/anything

I'm using Sprint boot to run a web application. I did not configure any classes explicitly. I have a strange problem. When running the web server using gradle bootRun, I am able to access files that are directly under webapp folder but not a sub-folder like webapp/something.
I'm not posting any code here because there is nothing explicitly I configured different from a default spring boot web app. I'm using structure as in https://github.com/jhipster/jhipster-sample-app-gradle
Anyone faced this problem before ?

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.

Resources