java.lang.NoClassDefFoundError:org / hibernate / cfg /修改XML后的配置

时间:2013-01-30 10:48:55

标签: xml eclipse hibernate exception

我的项目工作到那时我试图将字符编码设置为UTF-8。 我将<property name="hibernate.connection.characterEncoding">utf8</property>行添加到hibernate.cfg.xml。 现在计算机重启后,我收到了这个奇怪的错误:

java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
    at dal.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:15)
    at dal.hibernate.HibernateDAOFactory.getSession(HibernateDAOFactory.java:25)
    at dal.hibernate.HibernateUserDAO.authenticate(HibernateUserDAO.java:23)
    at controller.servlet.LogIn.doPost(LogIn.java:63)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.hibernate.cfg.Configuration
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
    ... 22 more

堆栈中的前四个类是我的类。

我看到new Configuration();调用导致错误,但我在WEB-INF / lib中有必要的JAR:

  • ANTLR-2.7.7.jar
  • DOM4J-1.6.1.jar
  • 冬眠-公地注解-4.0.1.Final.jar
  • 冬眠核-4.1.9.Final.jar
  • 冬眠-JPA-2.0-API-1.0.1.Final.jar
  • 了Javassist-3.17.1-GA.jar
  • 的JBoss-测井3.1.0.GA.jar
  • 的JBoss-事务api_1.1_spec-1.0.0.Final.jar
  • MySQL的连接器的Java-5.1.18-bin.jar

以下是配置XML:

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost/web_projekt</property>
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.connection.password">******</property>
        <property name="hibernate.connection.pool_size">10</property>
        <property name="hibernate.connection.characterEncoding">utf8</property>
        <property name="show_sql">true</property>
        <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="hibernate.hbm2ddl.auto">update</property>

        <!-- Mapping files -->
        <mapping resource="core/bean/tables.hbm.xml"/>
    </session-factory>
</hibernate-configuration>

你知道这是什么问题吗?

0 个答案:

没有答案