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.
Related
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.
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 ?
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.
I made a little web app with Spring Boot with web MVC, it is working fine if I run it by deploying the war or if I run it directly from STS. The problem is that my application is always run with his appname as context app (something like "localhost:8080/appname/") and I can't change it. I tried to write a web.xml with dispater-config.xml but, even if the server recognize it, the path is not changed. I tried to write the method in the SpringBootServletInitializer and setting the path, but it is not working too. I also tried to add a META-INF/context.xml in the webapp folder trought STS (project->src->webapp->META-INF->context.xml) but it's not working too. I am just going crazy with, what should i do to change the app's context path? Thanks
EDIT: I would mount my app in the root context of tomcat
It's built in, in eclipse (STS). I suggest using a stand alone tomcat and not the integrated eclipse tomcat and deploy the war on your stand alone tomcat
Add the context path as a parameter to your #RequestMapping annotation, like this: #RequestMapping("/helloworld")
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.