Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring MVC App runs in Eclipse but not Intellij - 404 Not Found

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.

like image 813
erik-sn Avatar asked Sep 23 '15 13:09

erik-sn


1 Answers

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.

like image 167
erik-sn Avatar answered Nov 14 '22 06:11

erik-sn