java.lang.NoSuchMethodError:org.objectweb.asm.ClassWriter

时间:2011-05-16 14:07:00

标签: hibernate java-ee-6

您好我正在使用hibernate2开发一个小应用程序,我碰到了读取java.lang.NoSuchMethodError的异常:org.objectweb.asm.ClassWriter

这是stacktrace:

INFO: connection properties: {user=root, password=manel}
16 mai 2011 16:03:27 net.sf.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Transaction strategy: net.sf.hibernate.transaction.JDBCTransactionFactory
16 mai 2011 16:03:27 net.sf.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
16 mai 2011 16:03:28 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use scrollable result sets: true
16 mai 2011 16:03:28 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use JDBC3 getGeneratedKeys(): true
16 mai 2011 16:03:28 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: false
16 mai 2011 16:03:28 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
16 mai 2011 16:03:28 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: cache provider: net.sf.hibernate.cache.EhCacheProvider
16 mai 2011 16:03:28 net.sf.hibernate.cfg.Configuration configureCaches
INFO: instantiating and configuring caches
Exception in thread "main" java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(Z)V
at net.sf.cglib.core.DebuggingClassWriter.<init>(DebuggingClassWriter.java:47)
at net.sf.cglib.core.DefaultGeneratorStrategy.getClassWriter(DefaultGeneratorStrategy.java:30)
at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:24)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:215)
at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:145)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:117)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
at net.sf.hibernate.impl.SessionFactoryImpl.<clinit>(SessionFactoryImpl.java:236)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:791)
at hibernate.dao.SessionHibernate.rebuildSessionFactory(SessionHibernate.java:68)
at hibernate.dao.SessionHibernate.getSession(SessionHibernate.java:51)
at hibernate.dao.TimesheetDAO.addTimesheet(TimesheetDAO.java:74)
at TestHibernate.main(TestHibernate.java:14)

任何帮助,请

2 个答案:

答案 0 :(得分:3)

您需要在类路径中使用正确版本的asm jar

答案 1 :(得分:0)

你的lib有些冲突。 hibernate使用 cglib-xxxx.jar ,它使用 asm-xxxx.jar 。并且有可能在您的项目中使用这些jar的多个版本,或者您正在使用的其他库也可能对某些其他版本有一些依赖性,因此它会相互冲突。
您需要删除 cglib-xxxx.jar 并替换为 cglib-nodep-xxxx.jar 并使用最新的 asm-xxxx.jar 或尝试从hibernate依赖项中删除 asm-xxxx.jar ,因为 cglib-nodep-xxx.jar 会查找另一个最新的 asm-xxxx.jar < / strong>在您的项目或Web服务器库中。您可以从链接中找到 cglib-nodep lib 的 http://sourceforge.net/projects/cglib/files/