I try to run a basic Spring MVC application, like the one here (or also the Spring MVC tutorial here).
I just open the project in IntelliJ, import it on a Tomcat 7 instance, and start the Tomcat server. But when I try to reach the http://localhost:8080, I get a 404 error.
The project I downloaded from GitHub provides 2 ways to start the application, with mvn jetty:run or mvn tomcat7:run. When I run any of these commands (outside IntelliJ), the application starts succesfully, and the web page is displayed correctly on the http://localthost:8080 URL, which led me think that the problem comes from IntelliJ.
Adding some debug information, it appears that when run under IntelliJ, the WebInitializer class is loaded, but not the WebConfig class, even if the method WebInitializer.getServletConfigClasses() is called.
With mvn jetty:run or mvn tomcat7:run, both classes are correctly instantiated.
Unfortunately, I have no error at all in any logs provided by Tomcat / IntelliJ, so I'm a bit lost.
What I am doing wrong, or what I've missed in the configuration of my project in IntelliJ?
Thanks
Technical info: Java 7, Tomcat 7, IntelliJ Ultimate 12.1.4, Spring 3.2.2.RELEASE
My problem is solved. I was using Tomcat 7.0.8 in IntelliJ, while the tomcat7-maven-plugin relies on Tomcat 7.0.30.
So I downloaded the latest version, 7.0.42, and now IntelliJ is working fine.
I'm not sure what feature was missing in the 7.0.8, but IntelliJ was not able to start my Spring MVC application correctly.
Related
I have a web application which includes Spring Boot , Joinfaces , JSF and Spring Security. This web application works excellent when i run in ECLIPSE IDE. All pages works fine with 0 Error.
The thing is when i do mvn install and package this project into WAR and deploy it in TOMCAT its just not working. No deploy error. Just 404 when i try to reach my pages.
What can cause this ? Why it is working perfectly fine on Eclipse but not working on Tomcat after packaging ?
Where should i look to solve this ?
I found the problem.
The thing is rest of the project was built to be run on embedded Tomcat as JAR. So the packaging was the problem. I ran the application as java -jar on tje distant machine and it worked.
I'm trying to deploy a java web application to Tomcat using Visual Studio Code and I'm having some issues that I'd like to share.
After installing the extension Tomcat for Java, I've tried to deploy a Maven Java Web project. To do so, I've clicked over project's folder and selected "Run on Tomcat Server" option. The result is an error with this message: The folder is not a valid web app to run on Tomcat Server.
Then, I've realized that maybe I should create a war file before running it on Tomcat. Therefore, I've executed mvn clean package command and afterwards execute "Run on Tomcat Server" option over the war file. Doing this the project has been deployed correctly.
However, compared to Eclipse's way to work with Tomcat, it seems to me a bit tedious. Particularly if I'm working with static files, like css or js, because every time I modify a file I should execute mvn clean package and "Run on Tomcat Server". Whereas, in Eclipse, these files are deployed automatically on Tomcat without restarting.
I wonder if there is another way to work with VS Code and Tomcat for Java.
Thanks!
If you use Spring, there is an easy way.
The Spring Initializr extension comes with an embedded Tomcat installation, and hot reloading works out of the box.
Rely on the following guide to install it:
https://code.visualstudio.com/docs/java/java-spring-boot
I am using an archetype from Maven called "spring-mvc-webapp, 1.0.0CR8" in my eclipse project. Infact i have not done anything to the project yet. I just want to deploy it and test it with the default application that comes with the archetype. I have spent hours trying to fix it but with no success
I call my application from the browser like localhost:8080/myapp and i get forbidden in the browser. But when i go to localhost:8080 i see the default home page of wildfly. When i go also to the management console of Wildfly, i see that my app is deployed yet it is not working.
Any idea to fix it is appreciated.
I've written a Spring MVC app that is functional on an app server. I'm attempting to switch development of this app from Eclipse and to Intellij. I am very new to the IDE so I'm not sure where I have gone wrong here.
When I run this application on the server in Eclipse it goes to localhost just fine and works as expected. I created a run configuration in IntelliJ, the app compiles and the server log says it was deployed successfully.
However in the browser it gives the standard HTTP Status 404 - Resource Not Available.
I really don't think it's the servlet or web.xml because those are working just fine in Eclipse. I've also created a brand new app in Intellij to test it and it works fine. So it must be something specific to IntelliJ that I have misconfigured or not setup at all...any ideas? Let me know if you need to see specific screens or anything.
So after toying with this, making it worse a few times, and then getting it back to the original 404 I found the difference.
Eclipse has an internal tomcat server it runs projects on, Intellij runs its projects on the default tomcat server installed on your computer. Intellij exports the project you are running to the server in the web apps folder as the name of your project.
So after I found that, in my tomcat run configuration in Intellij I had to specifiy the application context. Edit Configurations -> Deployment tab -> Application context, and set it to /YourProjectName. My guess is that this tells tomcat where to find your project within the web apps folder.
I hope this can help anyone else who is a relative beginner to tomcat/java EE and intellij like I am.
There is a plugin in intellij called "Smart Tomcat", it allows running spring or web app with much fewer configurations.
I am new in spring.I imported one spring project in eclipse and try to run with apache tomcat but it is not running.There is no main method in project.It contains only controllers and models and one jsp page.When i tried to run as a java application is shows below dialog. Please help me.I tried all in google for how to run spring project but i can't understand.Please tell me how to do?
Assuming you have added tomcat to your eclipse.
If your project is pure java project then it will not show you the run on server option in eclipe. You need to change project facet and add dynamic web module to it then you can run it on tomcat server from eclipse.Basically project needs to be web project.
After doing above if it gives error or do not run properly, check your project deployment assembly and add projects webapps folder in eclipse.
you need to have a tomcat installed in your eclipse and run it on the server.
Here is a tutorial to do this
You need to install the Web Tools Platform, which has support for the usual Web-application tools.