This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet

 
Joseph Sweet
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone,

I am trying to follow a very rudimentary Spring tutorial.

http://viralpatel.net/blogs/2010/06/spring-3-mvc-create-hello-world-application-spring-3-mvc.html

It seems like the writer has forgotten to add the jars that he puts in WebContent\WEB-INF\lib folder to the project's Java build path. However I have added. Actually, just to avoid problems, I have added to the Java build path all the files that are in my \spring\spring-framework-3.0.4.RELEASE\dist folder.

The problem is that when running, I am getting exceptions, and the application is not being deployed in tomcat\webapps.

I am not sure what all the exceptions are, since there too many for the Eclipse console window.
But those that I can see are: java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet

Also, at the bottom of the console it says INFO: Servlet spring is currently unavailable

What could be the problem?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It could be the class isn't there--have you checked the jar(s)?
 
Joseph Sweet
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it is in the org.springframework.web.servlet-3.0.4.RELEASE.jar
BTW, is there a command line way to check such a thing automatically?
 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

BTW, is there a command line way to check such a thing automatically?

I wrote a simple Groovy script for that and blogged about it here.
 
Joseph Sweet
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Freddy, a lot of handy stuff.

I just read there's also an option to use
jar tvf * | grep DispatcherServlet

http://download.oracle.com/javase/1.4.2/docs/tooldocs/solaris/jar.html

Any help with my original question?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using a plugin to launch the web application ? If yes, you may have to configure it to use your lib folder, and not somewhere else.
 
Joseph Sweet
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am just using the recent Eclipse for JEE applications.
I did not install the Spring IDE Eclipse plugin. When you use that plugin, the process is somewhat different than the one described in the above mentioned tutorial.
They also do not mention that plugin in the tutorial.
Since I have included the jars in the project's Java build path, I do not understand what the problem might be.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At the end of the tutorial, they say "I assume you have already configured Tomcat in eclipse. ". Have you ?
 
Joseph Sweet
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is already an instance of Tomcat v6.0 at localhost in the Servers window. I think it got there automatically when I selected the target runtime environment (look above at the tutorial, where it says "Once this is done, select the target runtime environment (e.g. Apache Tomcat v6.0)").
(see attached image)

I have just noticed there was another project as well located under that server, so I removed it so only the project named "Spring3MVC" was left.
Now when I run this project, I get this error:



In the browser window I get:

eclipse.jpg
[Thumbnail for eclipse.jpg]
Eclispe Servers window
 
Joseph Sweet
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems to me like the problem lies in the

SEVERE: Error starting static Resources
java.lang.IllegalArgumentException: Document base J:\my_java\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\Spring3MVC does not exist or is not a readable directory


Does it mean something is wrong with my Eclipse settings? How could I fix this?
 
Peter Mularien
Author
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1> Does that directory exist?
2> With Eclipse WTP, it's often easiest to just delete the configured server and create a new one if you run into problems. Then redeploy your web application(s). Depending on the Eclipse WTP version you are using, some of the other available options for cleaning up may or may not work.
 
Joseph Sweet
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have been out of town. I just got back to this. It still does not work.

So, why do I get that "ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet" ???

I have added all the jars in the spring/dist folder to the project path.

Here is the output (from eclipse's console).

I appreciate your ideas.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic