aspose file tools*
The moose likes Other Application Frameworks and the fly likes ClassNotFoundException for SpringMVC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "ClassNotFoundException for SpringMVC" Watch "ClassNotFoundException for SpringMVC" New topic
Author

ClassNotFoundException for SpringMVC

vivien siu
Ranch Hand

Joined: Nov 10, 2005
Posts: 143
Hi I got this error:
Failed to load servlet: java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet


I am building the application on Websphere App Developer 5.1.1, JDK 1.3. And I have imported the Spring.Jar into my classpath

this is my web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>tradingapp</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>tradingapp</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

</web-app>


and I run my application by starting with this jsp page:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">

<% response.sendRedirect("/portfolio.htm"); %>


Can somebody help me please? I am baffled because how come it's throwing a ClassNotFoundException when I have the Spring.jar inside?


I'm not available, my BF's name is WORK.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Avoid carriage return. I think you have an extra space before the package name.
Try again with :
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>


[My Blog]
All roads lead to JavaRanch
vivien siu
Ranch Hand

Joined: Nov 10, 2005
Posts: 143
Hi, it is not carriage return that cause this problem
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

1. Did you at least try to remove the extra space before the classname ?
2. Did you solve your problem ?
vivien siu
Ranch Hand

Joined: Nov 10, 2005
Posts: 143
FYI, the extra space you see here is caused by the formatting of posts in javaranch

yup the problem is solved but kind of weird because the Spring.jar is not inside the lib folder of my application, but I point it to an external location. After the spring.jar is copied over to the lib folder inside my app. the thing works fine.

new question:
I keep getting this exception for my application:
[INFO] ConnectionProviderFactory - Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider
[WARN] JDBCExceptionReporter - SQL Error: 0, SQLState: null
[ERROR] JDBCExceptionReporter - Cannot load JDBC driver class 'jdbc racle:thin:@localhost:1521:CCPM'
[WARN] SettingsFactory - Could not obtain connection metadata <org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'jdbc racle:thin:@localhost:1521:CCPM'>org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver


I didn't include any oracle drivers because the rest of the team didn't include any. Do I need the oracle driver to make it work?

one more thing, why is it that Spring requires so many jar files?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

FYI, the extra space you see here is caused by the formatting of posts in javaranch

Haha, ok

I didn't include any oracle drivers because the rest of the team didn't include any. Do I need the oracle driver to make it work?

I'm not sure this problem is with your driver, but with the way you've set the JDBC settings.
Are you sure you've set the driver's class to the correct classname ? (oracle.jdbc.driver.OracleDriver). Reading the error message, it looks like you've set the database URL to the driver's classname.

one more thing, why is it that Spring requires so many jar files?

So many ? It is not Spring which needs so many jar files, but your application
vivien siu
Ranch Hand

Joined: Nov 10, 2005
Posts: 143
hahaha it took me a long time only I realise my driver class is wrongly set to my url LOL...

but anyway I have to add the Oracle driver to make it work.

whew! I added like 16 jar files? I am using JDK1.3 to do this application though so maybe it's because of a couple of JAr files just to read the xmls alone.

what I added was: commons-logging.jar, spring.jar, xml-apis.jar, xercesImpl.jar, commons-dbcp.jar, commons-pool, jdbc2_0-stdext.jar, commons-collections, hibernate3, dom4j-1.6, hibernate-annotations, ehcache-1.1, jta, classes12, cglib-nodep, antlr....
HarshalDilip Shah
Greenhorn

Joined: Feb 25, 2010
Posts: 5
For eclipse Galileo
in WEB-INF/lib add the following jar files spring.jar, spring-web.jar, spring-webmvc.jar,spring-core.jar
. These are present in the unzipped spring-framework-2.5.4 package
under dist folder
and under root folder
 
 
subject: ClassNotFoundException for SpringMVC