我正在使用spring3.1.1 + hibernate3.6.0 + tomcat7.0.29 + mysql5.5进行Java Web开发,但是在服务器上运行后,Eclipse提示

 HTTP Status 500 - Handler processing failed; nested exception is java.lang.NoClassDefFoundError:       org/springframework/orm/hibernate3/support/HibernateDaoSupport

详细如下,
类型例外报告
message Handler processing failed; nested exception is java.lang.NoClassDefFoundError:            org/springframework/orm/hibernate3/support/HibernateDaoSupport

description The server encountered an internal error (Handler processing failed; nested exception is java.lang.NoClassDefFoundError:     org/springframework/orm/hibernate3/support/HibernateDaoSupport) that prevented it from fulfilling this request.

例外
org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoClassDefFoundError:       org/springframework/orm/hibernate3/support/HibernateDaoSupport



org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:972)


org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause

java.lang.NoClassDefFoundError:   org/springframework/orm/hibernate3/support/HibernateDaoSupport
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClass(ClassLoader.java:791)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
 org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2901)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1170)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
cc.fanbang.api.manager.DBManager.addUser(DBManager.java:139)
 cc.fanbang.api.controller.TestController.handleDBManagerTestRequest(TestController.java:42)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
 org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
  org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
  org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause

java.lang.ClassNotFoundException:      org.springframework.orm.hibernate3.support.HibernateDaoSupport
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClass(ClassLoader.java:791)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2901)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1170)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
cc.fanbang.api.manager.DBManager.addUser(DBManager.java:139)
     cc.fanbang.api.controller.TestController.handleDBManagerTestRequest(TestController.java:42)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
   org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
   org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
  org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
 org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

我不明白为什么它告诉我没有hibernatedaosupport,并且已经将其导入到项目中的引用库和web-inf / lib中。
我导入的软件包如下
 commons-beanutils-1.8.3.jar
    commons-coder-1.4.jar
    commons-io-2.3.jar
    commons-lang-2.6.jar
    commons-logging-1.1.1.jar
    ezorph-1.0.6.jar
    json-lib-2.4-jdk15.jar
    jstl-1.2.jar
    org.springframework.asm-3.1.1.release.jar
    org.springframework.beans-3.1.1.release.jar
    org.springframework.context-3.1.1.release.jar
    org.springframework.core-3.1.1.release.jar
    org.springframework.expression-3.1.1.release.jar
    org.springframework.web.servlet-3.1.1.release.jar
    org.springframework.web-3.1.1.release.jar
    servlet-api.jar
    antlr-2.7.6
    c3p0-0.9.1.jar
    commons-collections-3.1.jar
    dom4j-1.6.1.jar
    ehcache-1.5.0.jar
    hibernate-jpa-2.0-api-1.0.1.final.jar
    hibernate3.jar
    javassist-3.12.0.ga.jar
    jta-1.1.jar
    mysql-connector-java-5.1.12-bin.jar
    org.springframework.orm-3.1.1.release.jar
    org.springframework.jdbc-3.1.1.release.jar
    org.springframework.aop-3.1.1.release.jar
    org.springframework.transaction-3.1.1.release.jar
    slf4j-api-1.6.1.jar
    slf4j-nop-1.6.1.jar

以及与事务处理有关的applicationContext.xml的部分内容如下,
<bean id="transactionManager"           class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>

<tx:advice id="txAdvice" transaction-manager="transactionManager">
    <tx:attributes>
        <tx:method name="get*" read-only="true" />
        <tx:method name="*" />
    </tx:attributes>
</tx:advice>

<aop:config>
    <aop:pointcut id="fbPointcut" expression="bean(dbManager)" />
    <aop:advisor advice-ref="txAdvice" pointcut-ref="fbPointcut" />
</aop:config>

最佳答案

NoClassDefFoundError意味着类加载器找不到org.springframework.orm.hibernate3.support.HibernateDaoSupport依赖的类。并不是说HibernateDaoSupport本身不丢失。查找缺少哪个依赖项的最佳方法是查看 HibernateDaoSupport 的import部分

看来您的类路径中缺少org.springframework.dao库。

09-05 01:51