879 words

How to resolve 404 errors with Eclipse/Maven Spring MVC

#1
2013-02-07 17:57

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).

siegfried
siegfried's picture
Joined on 2013-02-07
User Post #1
#2
2013-02-08 01:57

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
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #1,416
#3
2013-02-09 05:02

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

siegfried
siegfried's picture
Joined on 2013-02-07
User Post #2
#4
2013-02-09 22:29

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
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #1,420
#5
2013-02-11 03:14

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

siegfried
siegfried's picture
Joined on 2013-02-07
User Post #3
#6
2013-02-11 19:17

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

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #1,423
#7
2013-02-11 19:27

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

(2) Download tomcat 6 from http://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

 

siegfried
siegfried's picture
Joined on 2013-02-07
User Post #4
#8
2013-02-11 19:42

Should I use the workspace from #3 above?

How should I use the zip from #5 above?

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #1,424
#9
2013-02-11 19:47

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

siegfried
siegfried's picture
Joined on 2013-02-07
User Post #5
#10
2013-02-11 19:53

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
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #1,425
#11
2013-02-11 20:03

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

siegfried
siegfried's picture
Joined on 2013-02-07
User Post #6
#12
2013-02-16 10:29

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
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #1,427

Post Reply

Please read carefully the posting instructions - before posting to the ObjectDB website.

  • You may have to disable pop up blocking in order to use the toolbar (e.g. in Chrome).
  • Use ctrl + right click to open the browser context menu in the editing area (e.g. for using a browser spell checker).
  • To insert formatted lines (e.g. Java code, stack trace) - select a style in the toolbar and then insert the text in the new created block.
  • Avoid overflow of published source code examples by breaking long lines.
  • You may mark in paragraph code words (e.g. class names) with the code style (can be applied by ctrl + D).
  • Long stack traces (> 50 lines) and complex source examples (> 100 lines) should be posted as attachments.
Attachments:
Maximum file size: 32 MB
Cancel