Hibernate和Jersey使用Tomcat和Eclipse IDE进行冲突 [英] Hibernate and Jersey conflicts using Tomcat and Eclipse IDE

查看:161
本文介绍了Hibernate和Jersey使用Tomcat和Eclipse IDE进行冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我正在使用Hibernate&泽西有一个图书馆冲突与Hibernate,泽西从以下链接我得到这样的



http://www.hildeberto.com/2008/05/hibernate-and-jersey-conflict-on.html



泽西使用ASM库,这也是Hibernate使用的,但是在不同的版本上。 Hibernate使用1.5.3版本,泽西使用3.5.1。有很大的区别!我们不能只是删除旧版本,而是把它们放在新的位置,因为它们在架构上是不同的。版本1.5.3有一个attrs包,而3.5.1没有它,而是一个签名包。
Cglib软件包需要ASM软件包,它是Hibernate库的一部分。如果我们删除该包,Jersey将正常工作,但是Hibernate将停止工作。为了解决这个冲突,请使用cglib-nodep.jar而不是cglib.jar,并保持ASM版本3.x与泽西。 cglib-nodep.jar包含一些由cglib.jar要求的ASM类,更改包名称以避免任何类冲突。



但包含 asm-3.1.jar asm-attrs-2.2.3.jar asm-commons- 3.1.jar asm-util-3.1.jar cglib-nodep-2.1_3sources.jar 我收到错误:



如果我放置 cglib 2.1.3

  java.lang.NoSuchMethodError:org.objectweb.asm.ClassWriter。< init>(Z)V 
at net.sf.cglib .core.DebuggingClassWriter。< init>(DebuggingClassWriter.java:47)
在net.sf.cglib.core.DefaultGeneratorStrategy.getClassWriter(DefaultGeneratorStrategy.java:30)

如果我放置 cglib-nodep-2.1_3-sources.jar

  java.lang.ClassNotFoundException:net.sf.cglib.core.KeyFactory 
在org.apache.catalina.loader.WebappClassLoader.loadClass (WebappClassLoader.java:1701)
a t org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)

请任何一个列出jar文件需要解决这个问题。

解决方案

如果我没有错,cglib不再是首选的字节码Hibernate提供程序。相反,Javassist是,您可以强制Javassist使用以下内容:

  hibernate.bytecode.provider = javassist 

在最近的Hibernate版本中,这已经是默认行为了。您必须具有旧版本的Hibernate,或者该项目已被配置为用cglib覆盖上述内容。所以您可以更新您的Hibernate版本,或者将您的实例配置为使用javassist。配置类型取决于您的环境和您想要的。一般来说,您在类路径中的hibernate.properties文件中包含上述行。我想你也可以添加 -Dhibernate.bytecode.provider = javassist 到命令行或JAVA_OPTS中进行JBoss配置。



您可以在这里看到更多的讨论和网络上的其他地方。只是Google hibernate.bytecode.provider


In my project I am using both Hibernate & Jersey there is a library conflict with Hibernate, Jersey from the below link I getting like this

http://www.hildeberto.com/2008/05/hibernate-and-jersey-conflict-on.html

Jersey uses the ASM library, which is also used by Hibernate, but on different versions. Hibernate uses version 1.5.3 and Jersey uses 3.5.1. A big difference! We can not just delete the old version and put the new one there because they are architecturally different. Version 1.5.3 has an "attrs" package while 3.5.1 doesn't have it but a "signatures" package. The ASM package is needed by the cglib package, which is part of the Hibernate libraries. If we remove that package, Jersey will work correctly, but Hibernate will stop working. To solve this conflict use cglib-nodep.jar instead of cglib.jar and keep ASM version 3.x with Jersey. cglib-nodep.jar includes some ASM classes demanded by cglib.jar, changing the package name to avoid any class conflict.

but after including the asm-3.1.jar, asm-attrs-2.2.3.jar, asm-commons-3.1.jar, asm-util-3.1.jar, cglib-nodep-2.1_3sources.jar I am getting errors:

if I place cglib 2.1.3:

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)

if I place cglib-nodep-2.1_3-sources.jar:

java.lang.ClassNotFoundException: net.sf.cglib.core.KeyFactory
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)

please any one list the jar files need to resolve this issue.

解决方案

If I'm not mistaken, cglib is no longer the preferred bytecode provider for Hibernate. Rather Javassist is and you can force Javassist with the following:

hibernate.bytecode.provider=javassist

In recent versions of Hibernate, this is already the default behavior. You must either have an older version of Hibernate, or the project is already being configured to override the above with cglib. So you can either update your version of Hibernate, or configure your instance to use javassist instead. Configuration kind of depends on your environment and what you want. In general, you include the above line in a hibernate.properties file in your classpath. I think you can also add -Dhibernate.bytecode.provider=javassist to command line or in JAVA_OPTS for JBoss configuration.

You can see more discussion here and elsewhere on the web. Just Google hibernate.bytecode.provider

这篇关于Hibernate和Jersey使用Tomcat和Eclipse IDE进行冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆