How to resolve 404 errors with Eclipse/Maven Spring MVC

#1

I have created a project as guided by www.objectdb.com/tutorial/jpa/eclipse/spring/run. When I abandon eclipse and use the maven command line to deploy this Spring MVC web app to jetty and point my browser to localhost:8080/Guestbook/ it works as your tutorial says!

However, when I use  Eclipse Juno (eclipse-jee-juno-SR1-win32-x86_64), maven 3 and Tomcat 6 to create a new maven project (with a dynamic web facet) and add Tomcat 6 as a server, it asks me if I want to move my guestbook app with the cute little jar icon from the left side to the tomcat side. I say yes and it appears under the that server icon in the server. But when I point the browser to localhost:8080/Guestbook after starting the tomcat6 it gives me the 404 error: "type Status report/message /Guestbook/ description The requested resource is not available. Apache Tomcat/6.0.36"

I'd love to use eclipse to single step thru the source code. Also, to remove the one syntax error that eclipse was giving me, I commented out the com.objectdb.Enhancer. Is this optional when deploying with eclipse instead of maven? I think so. Can someone help me! I've tried a lot of other tutorials and this is the only I can get to work at all! I love the fact that this tutorial also does JPA. 
Thanks
Siegfried (P.S. this is partially cross posted with the eclipse forum. After posting there I thought it would be more appropriate to post here).

#2

Enhancement (using com.objectdb.Enhancer or other method) is optional, but improves performance.

You may post your tutorial based Eclipse project that doesn't work.

ObjectDB Support
#3

Please see http://www.heintze.com/temp/hello-spring-mvc-annotated-tomcat6.zip .

I don't know why it is so large (104MB). I just zipped up the eclipse workspace because there was only one project in it.

I suppose deleting the class files in the bin directory might save a few KB. I'm guessing the groovy and maven pluggins are large? I think those are the only pluggins.

As I recall, I made this by using the import feature in the file menu of eclipse to import the directory I created by unzipping the maven version of your tutorial. In this version eclipse won't make the jar file to copy to tomcat and I don't know why. In the version were I manually created the files following your tutorial for eclipse, it will create a little jar icon underneath the tomcat 6 server icon indicating the jar has been deployed to the tomcat6 server. Neither version will run with tomcat 6. Both versions will run with "mvn> jetty:run".

Thank you (very much!) for taking a look at it!

Siegfried

#4

I opened the workspace in Eclipse Juno (eclipse-jee-juno-SR1-win32-x86_64), but the project explorer is closed and cannot be opened. Where is the project directory?

ObjectDB Support
#5

Sorry! Apparently the import feature in eclipse does not work the way I thought. I assumed the source files would be in that directory.

Here is another (100MB) zip file created from a directory that was created by eclipse and the source code files were created by cutting and pasting into eclipse (instead of importing a project):

http://www.heintze.com/temp/hello-spring-mvc-annotated-tomcat6-from-scratch.zip

I't is still kinda crazy for a half dozen source code files.

I look forward to your response!

Thanks

Siegfried

#6

Please provide instructions on how to use this and/or the previous zip.

ObjectDB Support
#7

(1) This is the source code downloaded from http://www.objectdb.com/tutorial/jpa/start/maven.

(2) Download tomcat 6 from https://tomcat.apache.org/download-60.cgi .Adjust the settings for the tomcat 6 server in eclipse so they point to the directory where you installed or unzipped tomcat 6. I did not use the windows installer, instead I just unzipped it in a logically named directory.

(3) Verify maven 3 is installed and verify it works fine from eclipse using the maven build command to do a jetty:run command. Point the browser as the tutorial explains: http://localhost:8080/Guestbook.

(4) stop jetty

(5) click on the servers tab. Right click on Tomcat 6 server->add remove->move guestbook to the right hand "configured" pane.

(6) Start the tomcat 6 server by clicking on the green triangular icon.

(7) Point the browser at http://localhost:8080/Guestbook and observe (and please fix!) the 404 error!

 

Thanks!

Siegfried

 

#8

Should I use the workspace from #3 above?

How should I use the zip from #5 above?

ObjectDB Support
#9

I was able to make maven and work both from the eclipse maven plugin and directly from the maven command line. Jetty should work from both places for you too. Either will do.

What I cannot figure out how to do is single step thru the controller class using eclipse/tomcat 6. Please verify that you can run the Guestbook app from eclipse and single step debug thru the controller class.

 

Thanks

siegfried

#10

I am not sure I understand.

Is it a problem with running the tutorial with Tomcat or with using the debugger in this context?

ObjectDB Support
#11

I assume there is no point in trying to run the debugger if the webapp Guestbook won't run at all and only gives 404 errors when launched from eclipse. I cannot get it to run at all from from eclipse with tomcat6 because I just get 404 errors.

I'm hopeful that once we fix these 404 errors, I can easily set a break point in the controller class and single step with the eclipse debugger.

Thanks

Siegfried

#12

The attached Eclipse Juno project was built by following the tutorial step by step, but updating the pom.xml file to use newer versions of the Spring Framework and ObjectDB (apparently older versions of the Spring Framework conflict with Eclipse Juno).

It works well with Tomcat 7 (Tomcat 6 wasn't tested).

ObjectDB Support

Reply