hibernate org.objectweb.asm.classwriter

发布于 2024-11-07 02:15:07 字数 4455 浏览 0 评论 0原文

当我运行我使用 hibernate 的 java 应用程序时出现此错误:

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

和我添加了 asm

控制台的所有 jars:

12 mai 2011 09:57:53 net.sf.hibernate.cfg.Environment <clinit>
INFO: Hibernate 2.1.6
12 mai 2011 09:57:53 net.sf.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
12 mai 2011 09:57:53 net.sf.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
12 mai 2011 09:57:53 net.sf.hibernate.cfg.Configuration configure
INFO: configuring from file: hibernate.cfg.xml
12 mai 2011 09:57:53 net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: org/projet/Timesheet.hbm.xml
12 mai 2011 09:57:53 net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: org.projet.Timesheet -> timesheet
12 mai 2011 09:57:53 net.sf.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
12 mai 2011 09:57:53 net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-many association mappings
12 mai 2011 09:57:53 net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-one association property references
12 mai 2011 09:57:53 net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
12 mai 2011 09:57:53 net.sf.hibernate.dialect.Dialect <init>
INFO: Using dialect: net.sf.hibernate.dialect.MySQLDialect
12 mai 2011 09:57:53 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Maximim outer join fetch depth: 2
12 mai 2011 09:57:53 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use outer join fetching: true
12 mai 2011 09:57:53 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
12 mai 2011 09:57:53 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
12 mai 2011 09:57:53 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql://localhost:3306/timesheet
12 mai 2011 09:57:53 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=root, password=manel}
12 mai 2011 09:57:53 net.sf.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Transaction strategy: net.sf.hibernate.transaction.JDBCTransactionFactory
12 mai 2011 09:57:53 net.sf.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
12 mai 2011 09:57:53 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use scrollable result sets: true
12 mai 2011 09:57:53 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use JDBC3 getGeneratedKeys(): true
12 mai 2011 09:57:53 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: false
12 mai 2011 09:57:53 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
12 mai 2011 09:57:53 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: cache provider: net.sf.hibernate.cache.EhCacheProvider
12 mai 2011 09:57:53 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 org.projet.ModelTime.configure(ModelTime.java:28)
    at org.projet.TestClient.main(TestClient.java:19)

i get this error when i run my java application i work with hibernate :

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

and i added all jars of asm

console:

12 mai 2011 09:57:53 net.sf.hibernate.cfg.Environment <clinit>
INFO: Hibernate 2.1.6
12 mai 2011 09:57:53 net.sf.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
12 mai 2011 09:57:53 net.sf.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
12 mai 2011 09:57:53 net.sf.hibernate.cfg.Configuration configure
INFO: configuring from file: hibernate.cfg.xml
12 mai 2011 09:57:53 net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: org/projet/Timesheet.hbm.xml
12 mai 2011 09:57:53 net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: org.projet.Timesheet -> timesheet
12 mai 2011 09:57:53 net.sf.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
12 mai 2011 09:57:53 net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-many association mappings
12 mai 2011 09:57:53 net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-one association property references
12 mai 2011 09:57:53 net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
12 mai 2011 09:57:53 net.sf.hibernate.dialect.Dialect <init>
INFO: Using dialect: net.sf.hibernate.dialect.MySQLDialect
12 mai 2011 09:57:53 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Maximim outer join fetch depth: 2
12 mai 2011 09:57:53 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use outer join fetching: true
12 mai 2011 09:57:53 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
12 mai 2011 09:57:53 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
12 mai 2011 09:57:53 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql://localhost:3306/timesheet
12 mai 2011 09:57:53 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=root, password=manel}
12 mai 2011 09:57:53 net.sf.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Transaction strategy: net.sf.hibernate.transaction.JDBCTransactionFactory
12 mai 2011 09:57:53 net.sf.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
12 mai 2011 09:57:53 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use scrollable result sets: true
12 mai 2011 09:57:53 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use JDBC3 getGeneratedKeys(): true
12 mai 2011 09:57:53 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: false
12 mai 2011 09:57:53 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
12 mai 2011 09:57:53 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: cache provider: net.sf.hibernate.cache.EhCacheProvider
12 mai 2011 09:57:53 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 org.projet.ModelTime.configure(ModelTime.java:28)
    at org.projet.TestClient.main(TestClient.java:19)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

猫烠⑼条掵仅有一顆心 2024-11-14 02:15:07

当提供的库版本不具有所需的类时,就会发生这种情况。虽然没有通用的修复方法,但您可以尝试使用对我有用的方法。

您需要做的就是从 hibernate 中正确排除 ASM 库并单独包含它。看起来很模糊,但看一下工作 pom.xml 中的片段。这种方法背后的目的是包含项目中其他一些第三个库可能需要的更高版本的依赖库。

为了包含休眠实体管理器,我使用以下代码。

    <dependency>
     <groupId>org.hibernate</groupId>
     <artifactId>hibernate-entitymanager</artifactId>
     <version>${hibernate.version}</version>
    <exclusions>
        <exclusion>
         <groupId>asm</groupId>
         <artifactId>asm</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

在这里,我明确地将 asm 从 hibernate-entity manager 包含中排除,并在其旁边单独包含它

    <dependency>
      <groupId>asm</groupId>
      <artifactId>asm</artifactId>
      <version>${asm.version}</version>
    </dependency>

,并且属性是。这些版本选择在最新的项目中对我有用。

    <properties>
            <hibernate.version>3.6.0.Final</hibernate.version>
            <asm.version>3.3</asm.version>
    </properties>

希望这能解决您的问题。

This happens when the supplied library version is not having the classes required. There is no general fix though but you can try with this approach which worked for me.

All you need to do is to have a proper exclusion of ASM libraries from hibernate and a separate inclusion of it. Seems fuzzy but take a look at the snippet from a working pom.xml. The intent behind this approach is to include a more later version of the dependent library which may be required by some other 3rd library in the project.

for including hibernate entity manager i am using following code.

    <dependency>
     <groupId>org.hibernate</groupId>
     <artifactId>hibernate-entitymanager</artifactId>
     <version>${hibernate.version}</version>
    <exclusions>
        <exclusion>
         <groupId>asm</groupId>
         <artifactId>asm</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

Here I am explicitly excluding asm from the hibernate-entity manager inclusion and next to it I am including it separately

    <dependency>
      <groupId>asm</groupId>
      <artifactId>asm</artifactId>
      <version>${asm.version}</version>
    </dependency>

and the properties are. These version choices worked for me in the latest project.

    <properties>
            <hibernate.version>3.6.0.Final</hibernate.version>
            <asm.version>3.3</asm.version>
    </properties>

Hope, this solves your problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文