Hibenate错误汇总:java.lang.NoClassDefFoundError:

xiaoxiao2021-02-28  36

原文地址为: Hibenate错误汇总:java.lang.NoClassDefFoundError:

有部分出自:http://www.reader8.cn/jiaocheng/20130911/2209649.html和http://blog.csdn.net/zmzsoftware/article/details/6835604。

一、 java.lang.NoClassDefFoundError:org.apache.lucene.index.CorruptIndexException

因为缺少lucene-core-3.0.2.jar包。

二、Hibenate异常汇总:java.lang.NoClassDefFoundError: org/jboss/logging/BasicLoggerException in thread "main" java.lang.NoClassDefFoundError: org/jboss/logging/BasicLoggerat java.lang.ClassLoader.defineClass1(Native Method)at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)at java.lang.ClassLoader.defineClass(ClassLoader.java:615)at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)at java.net.URLClassLoader.access$000(URLClassLoader.java:58)at java.net.URLClassLoader$1.run(URLClassLoader.java:197)at java.security.AccessController.doPrivileged(Native Method)at java.net.URLClassLoader.findClass(URLClassLoader.java:190)at java.lang.ClassLoader.loadClass(ClassLoader.java:306)at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)at java.lang.ClassLoader.loadClass(ClassLoader.java:247)at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:175)at hibernate.conn.HibernateUitl.<clinit>(HibernateUitl.java:16)at hibernate.conn.UserDAOImpl.saveUser(UserDAOImpl.java:112)at hibernate.conn.TestDAO.main(TestDAO.java:26)Caused by: java.lang.ClassNotFoundException: org.jboss.logging.BasicLoggerat java.net.URLClassLoader$1.run(URLClassLoader.java:202)at java.security.AccessController.doPrivileged(Native Method)at java.net.URLClassLoader.findClass(URLClassLoader.java:190)at java.lang.ClassLoader.loadClass(ClassLoader.java:306)at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)at java.lang.ClassLoader.loadClass(ClassLoader.java:247)... 16 more使用Hibernate4.0后,需要引入jboss-logging.GA.jar。

三、Exception in thread "main" java.lang.NoClassDefFoundError: javax/transaction/SystemExceptionat java.lang.Class.forName0(Native Method)at java.lang.Class.forName(Class.java:247)at org.jboss.logging.Logger.getMessageLogger(Logger.java:2248)at org.jboss.logging.Logger.getMessageLogger(Logger.java:2214)at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:175)at hibernate.conn.HibernateUitl.<clinit>(HibernateUitl.java:16)at hibernate.conn.UserDAOImpl.saveUser(UserDAOImpl.java:112)at hibernate.conn.TestDAO.main(TestDAO.java:26)Caused by: java.lang.ClassNotFoundException: javax.transaction.SystemExceptionat java.net.URLClassLoader$1.run(URLClassLoader.java:202)at java.security.AccessController.doPrivileged(Native Method)at java.net.URLClassLoader.findClass(URLClassLoader.java:190)at java.lang.ClassLoader.loadClass(ClassLoader.java:306)at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)at java.lang.ClassLoader.loadClass(ClassLoader.java:247)... 8 more添加/jboss-transaction-api_1.1_spec-1.0.0.Final.jar

四、Exception in thread "main" java.lang.NoClassDefFoundError: javax/persistence/EntityListenersat org.hibernate.cfg.annotations.reflection.JPAMetadataProvider.getDefaults(JPAMetadataProvider.java:97)at org.hibernate.annotations.common.reflection.java.JavaReflectionManager.getDefaults(JavaReflectionManager.java:226)at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1313)at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1727)at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1778)at hibernate.conn.HibernateUitl.<clinit>(HibernateUitl.java:18)at hibernate.conn.UserDAOImpl.saveUser(UserDAOImpl.java:112)at hibernate.conn.TestDAO.main(TestDAO.java:26)Caused by: java.lang.ClassNotFoundException: javax.persistence.EntityListenersat java.net.URLClassLoader$1.run(URLClassLoader.java:202)at java.security.AccessController.doPrivileged(Native Method)at java.net.URLClassLoader.findClass(URLClassLoader.java:190)at java.lang.ClassLoader.loadClass(ClassLoader.java:306)at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)at java.lang.ClassLoader.loadClass(ClassLoader.java:247)... 8 more解决方法:从hibernate的lib/jpa/下拷入hibernate-jpa-2.0-api-1.0.0.Final.jar包,OK,问题解决!

五、Caused by: org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersisterat org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:185)at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:135)at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:367)at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1740)at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1778)at hibernate.conn.HibernateUitl.<clinit>(HibernateUitl.java:18)... 2 moreCaused by: org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:138)at org.hibernate.tuple.entity.EntityTuplizerFactory.constructDefaultTuplizer(EntityTuplizerFactory.java:188)at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:341)at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:502)at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:144)at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)at java.lang.reflect.Constructor.newInstance(Constructor.java:513)at org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:163)... 7 moreCaused by: java.lang.reflect.InvocationTargetExceptionat sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)at java.lang.reflect.Constructor.newInstance(Constructor.java:513)at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:135)... 16 moreCaused by: java.lang.NoClassDefFoundError: javassist/util/proxy/MethodFilterat org.hibernate.bytecode.internal.javassist.BytecodeProviderImpl.getProxyFactoryFactory(BytecodeProviderImpl.java:56)at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactoryInternal(PojoEntityTuplizer.java:241)at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:219)at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:212)at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:82)... 21 moreCaused by: java.lang.ClassNotFoundException: javassist.util.proxy.MethodFilterat java.net.URLClassLoader$1.run(URLClassLoader.java:202)at java.security.AccessController.doPrivileged(Native Method)at java.net.URLClassLoader.findClass(URLClassLoader.java:190)at java.lang.ClassLoader.loadClass(ClassLoader.java:306)at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)at java.lang.ClassLoader.loadClass(ClassLoader.java:247)... 26 more添加javassist-3.15.0-GA.jar包

六、Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/collections/map/referenceMapat org.hibernate.engine.internal.StatefulPersistenceContext.<init>(StatefulPersistenceContext.java:167)at org.hibernate.internal.SessionImpl.<init>(SessionImpl.java:230)at org.hibernate.internal.SessionFactoryImpl$SessionBuilderImpl.openSession(SessionFactoryImpl.java:1801)at org.hibernate.internal.SessionFactoryImpl.openSession(SessionFactoryImpl.java:1009)at hibernate.conn.HibernateUitl.getSession(HibernateUitl.java:37)at hibernate.conn.UserDAOImpl.saveUser(UserDAOImpl.java:112)at hibernate.conn.TestDAO.main(TestDAO.java:26)Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections.map.referenceMapat java.net.URLClassLoader$1.run(URLClassLoader.java:202)at java.security.AccessController.doPrivileged(Native Method)at java.net.URLClassLoader.findClass(URLClassLoader.java:190)at java.lang.ClassLoader.loadClass(ClassLoader.java:306)at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)at java.lang.ClassLoader.loadClass(ClassLoader.java:247)... 7 more添加commons-collections-3.2.1.jar包七.Exception in thread "main" java.lang.NoClassDefFoundError: antlr/SemanticExceptionat java.lang.ClassLoader.defineClass1(Native Method)at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)at java.lang.ClassLoader.defineClass(ClassLoader.java:615)at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)at java.net.URLClassLoader.access$000(URLClassLoader.java:58)at java.net.URLClassLoader$1.run(URLClassLoader.java:197)at java.security.AccessController.doPrivileged(Native Method)at java.net.URLClassLoader.findClass(URLClassLoader.java:190)at java.lang.ClassLoader.loadClass(ClassLoader.java:306)at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)at java.lang.ClassLoader.loadClass(ClassLoader.java:247)at org.hibernate.loader.criteria.CriteriaQueryTranslator.<init>(CriteriaQueryTranslator.java:109)at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:84)at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1516)at org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java:374)at org.hibernate.internal.CriteriaImpl.uniqueResult(CriteriaImpl.java:396)at hibernate.conn.UserDAOImpl.findUserByName(UserDAOImpl.java:43)at hibernate.conn.TestDAO.main(TestDAO.java:34)Caused by: java.lang.ClassNotFoundException: antlr.SemanticExceptionat java.net.URLClassLoader$1.run(URLClassLoader.java:202)at java.security.AccessController.doPrivileged(Native Method)at java.net.URLClassLoader.findClass(URLClassLoader.java:190)at java.lang.ClassLoader.loadClass(ClassLoader.java:306)at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)at java.lang.ClassLoader.loadClass(ClassLoader.java:247)... 19 more我的异常网推荐解决方案:java.lang.ClassNotFoundException: javax.persistence.EntityListeners,http://www.myexception.cn/j2ee/182645.html我的异常网推荐解决方案:Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer],http://www.myexception.cn/eclipse/174629.html

八、com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failureLast packet sent to the server was 0 ms ago.at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)at java.lang.reflect.Constructor.newInstance(Constructor.java:526)at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2120)at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:723)at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)at java.lang.reflect.Constructor.newInstance(Constructor.java:526)at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:302)at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)at java.sql.DriverManager.getConnection(DriverManager.java:571)at java.sql.DriverManager.getConnection(DriverManager.java:187)at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(DriverManagerConnectionProviderImpl.java:193)at org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.prepare(SuppliedConnectionProviderConnectionHelper.java:51)at org.hibernate.tool.hbm2ddl.DatabaseExporter.<init>(DatabaseExporter.java:52)at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:367)at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:304)at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:293)at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:498)at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1754)at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1792)at com.user.TestHibernate.main(TestHibernate.java:14)Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failureLast packet sent to the server was 0 ms ago.at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)at java.lang.reflect.Constructor.newInstance(Constructor.java:526)at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:335)at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2043)... 21 moreCaused by: java.net.UnknownHostException: MySQL5at java.net.InetAddress.getAllByName0(InetAddress.java:1250)at java.net.InetAddress.getAllByName(InetAddress.java:1162)at java.net.InetAddress.getAllByName(InetAddress.java:1098)at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:243)at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:284)... 22 more

mysql服务器的名称不对,修改了MySQL为localhost正确的本地数据库名称,即可解决。

九、“com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure Last packet sent to the server was 0 ms ago.” 

上述问题是由mysql5数据库的配置引起的。mysql5将其连接的等待时间(wait_timeout)缺省为8小时。在其客户程序中可以这样来查看其值: mysql﹥ mysql﹥ show global variables like 'wait_timeout'; +---------------+---------+ | Variable_name | Value | +---------------+---------+ | wait_timeout | 28800 | +---------------+---------+ 1 row in set (0.00 sec) 28800 seconds,也就是8小时。 

如果在wait_timeout秒期间内,数据库连接(java.sql.Connection)一直处于等待状态,mysql5就将该连接关闭。这时,你的Java应用的连接池仍然合法地持有该连接的引用。当用该连接来进行数据库操作时,就碰到上述错误。这解释了为什么我的程序第二天不能登录 的问题。 你可能会想到在tomcat的数据源配置中有没有办法解决?的确,在jdbc连接url的配置中,你可以附上“autoReconnect=true”,但这仅对mysql5以前的版本起作用。增加“validation query”似乎也无济于事。 本人觉得最简单的办法,就是对症下药:既然问题是由mysql5的全局变量wait_timeout的缺省值太小引起的,我们将其改大就好了。 查看mysql5的手册,发现对wait_timeout的最大值分别是24天/365天(windows/linux)。以windows为 例,假设我们要将其设为21天,我们只要修改mysql5的配置文件“my.ini”(mysql5 installation dir),增加一行:wait_timeout=1814400需要重新启动mysql5。 linux系统配置文件:/etc/my.cnf 测试显示问题解决了。

转载请注明本文地址: Hibenate错误汇总:java.lang.NoClassDefFoundError:
转载请注明原文地址: https://www.6miu.com/read-1950393.html

最新回复(0)