I am using the sample project code here that i've downloaded from the following: http://javahash.com/spring-4-mvc-hello-world-tutorial-full-example/
Direct link here: http://javahash.com/wp-content/uploads/2014/02/Spring4MVCHelloWorld.zip
I have Eclipse Kepler SR2 (J2EE), Tomcat 7 64-bit, Java 7.
The project does not appear to be a web project, so I add "Dynamic Web Module" version 3.0 and "Java" (version 1.7) to it. I right click, maven install, which appears to run fine. When I try to actually deploy it on tomcat, it does not give any errors in the console, but when the browser window pops up it shows a 404
http://localhost:8080/Spring4MVCHelloWorld/
HTTP Status 404 - /Spring4MVCHelloWorld/
--------------------------------------------------------------------------------
type Status report
message /Spring4MVCHelloWorld/
description The requested resource is not available.
--------------------------------------------------------------------------------
Apache Tomcat/6.0.39
That said, how do I get this "basic" example running in eclipse? Anyone able to get this working successfully? It feels like it should be more trivial than the 5 hours I've spent on trying to get this sample code working to no avail.
UPDATE: Still continues to fail despite using Tomcat 7.0 server.
I tried going to:
http://localhost:8080/Spring4MVCHelloWord/hello
and the same:
HTTP Status 404 - /Spring4MVCHelloWorld/hello
shows up, but the tomcat shows up as:
Apache Tomcat/7.0.53
Note that this is the 64-bit version. What steps am I missing? How do I get around this silent failing?
As far as I can see your controller only maps to /hello
, which means your URL should be:
http://localhost:8080/Spring4MVCHelloWorld/hello
Another thing that might be interesting to you is that if your having problems with certain project facets (like Dynamic Web Module ) not being recognized, you can usually fix them by righ clicking your project, opening the Maven menu and choosing Update Project .
Apart from what Dimitri stated, your log seems to indicate that you are using
Apache Tomcat/6.0.39
That version of Tomcat does not support ServletContainerInitializer
which your Spring web application depends on for configuration. Upgrade to a Tomcat version 7+.
It seems like the Maven update doesn't work for you (or for me).
First, go into Properties -> Deployment Assembly
. You need to get rid of Web Content
if it's there and add src/main/webapp
(which is a maven convention). You also need to add the Maven Dependencies as shown below.
Finally, and this might not be necessary, delete the web.xml
provided to you and re-create it by selecting and right clicking Deployment Descriptor
in the Project Explorer and clicking Generate Deployment Descriptor Stub
.
Also, make sure your Java Build Path
in the Properties
has a Java 7+ version of the JRE.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.