aspose file tools*
The moose likes Spring and the fly likes ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet" Watch "ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet" New topic
Author

ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet

Joseph Sweet
Ranch Hand

Joined: Jan 29, 2005
Posts: 327
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?

We must know, we will know. -- David Hilbert
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

It could be the class isn't there--have you checked the jar(s)?
Joseph Sweet
Ranch Hand

Joined: Jan 29, 2005
Posts: 327
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

Joined: Sep 11, 2006
Posts: 959


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.


SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
Joseph Sweet
Ranch Hand

Joined: Jan 29, 2005
Posts: 327
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

Joined: Nov 24, 2005
Posts: 14688
    
  16

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.


[My Blog]
All roads lead to JavaRanch
Joseph Sweet
Ranch Hand

Joined: Jan 29, 2005
Posts: 327
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

Joined: Nov 24, 2005
Posts: 14688
    
  16

At the end of the tutorial, they say "I assume you have already configured Tomcat in eclipse. ". Have you ?
Joseph Sweet
Ranch Hand

Joined: Jan 29, 2005
Posts: 327
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:




[Thumbnail for eclipse.jpg]

Joseph Sweet
Ranch Hand

Joined: Jan 29, 2005
Posts: 327
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

Joined: Sep 06, 2007
Posts: 84
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.


Author, Spring Security 3 (the Book), Packt Publishing, 2010
SCJP, OCP
Joseph Sweet
Ranch Hand

Joined: Jan 29, 2005
Posts: 327
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.

 
wood burning stoves
 
subject: ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet