ASM 3.1 与 HIbernate 和 JAX-RS 的兼容性问题

发布于 2024-07-22 21:26:23 字数 279 浏览 6 评论 0原文

我发现“Hibernate 无法与 JAX-RS 的参考实现结合”。 在链接http://lists.jboss.org/pipermail/ hibernate-issues/2009-May/015628.html

所以我无法将 JAX-RS (球衣)与 hibernate 结合起来,有人知道解决这个问题的方法吗?

I have found out that "Hibernate cannot be combined with the reference implementation of JAX-RS." on the link http://lists.jboss.org/pipermail/hibernate-issues/2009-May/015628.html

So i am unable to combine JAX-RS (jersey) with hibernate, does anybody know a work around for this ?

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

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

发布评论

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

评论(4

任性一次 2024-07-29 21:26:23

万恶之源是cglib。 将 cglib-2.1.3.jar 替换为 cglib-nodep-2.1_3.jar 并删除 hibernate 的 asm*.jar 文件。

The root of evil is cglib. Substitute cglib-2.1.3.jar to cglib-nodep-2.1_3.jar and delete hibernate's asm*.jar files.

记忆之渊 2024-07-29 21:26:23

JerseyJava REST 框架)与 Hibernate 结合使用需要对 Maven 的 pom.xml 文件进行一些调整。 问题在于 Hibernate 使用 ASM 1.5.3,它与 Jersey 使用的 ASM 3.1 不兼容。

您需要做的是从 Hibernate 中排除一些传递依赖项:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate</artifactId>
    <version>3.2.6.ga</version>
    <exclusions>
        <exclusion>
            <groupId>asm</groupId>
            <artifactId>asm</artifactId>
        </exclusion>
        <exclusion>
            <groupId>asm</groupId>
            <artifactId>asm-attrs</artifactId>
        </exclusion>
        <exclusion>
            <groupId>cglib</groupId>
            <artifactId>cglib</artifactId>
        </exclusion>
    </exclusions>
</dependency>

然后,您需要包含正确的 ASM 版本:

<dependency>
    <groupId>asm</groupId>
    <artifactId>asm</artifactId>
    <version>3.1</version>
</dependency>

最后,您需要包含 CGLib 的 nodep 版本,它从 ASM 版本重新打包类1.5.3:

<dependency>
    <groupId>cglib</groupId>
    <artifactId>cglib-nodep</artifactId>
    <version>2.1_3</version>
</dependency>

来源:http://blog.idm.fr/2009 /04/jersey-hibernate-conflict.html

Using Jersey (the Java REST framework) in conjunction with Hibernate requires some tweaking of Maven's pom.xml file. The issue is that Hibernate uses ASM 1.5.3 which is incompatible with ASM 3.1 used by Jersey.

What you need to do is exclude some transitive dependencies from Hibernate:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate</artifactId>
    <version>3.2.6.ga</version>
    <exclusions>
        <exclusion>
            <groupId>asm</groupId>
            <artifactId>asm</artifactId>
        </exclusion>
        <exclusion>
            <groupId>asm</groupId>
            <artifactId>asm-attrs</artifactId>
        </exclusion>
        <exclusion>
            <groupId>cglib</groupId>
            <artifactId>cglib</artifactId>
        </exclusion>
    </exclusions>
</dependency>

Then, you need to include the correct version of ASM:

<dependency>
    <groupId>asm</groupId>
    <artifactId>asm</artifactId>
    <version>3.1</version>
</dependency>

Finally, you need to include a nodep version of the CGLib which repackages classes from ASM version 1.5.3:

<dependency>
    <groupId>cglib</groupId>
    <artifactId>cglib-nodep</artifactId>
    <version>2.1_3</version>
</dependency>

source: http://blog.idm.fr/2009/04/jersey-hibernate-conflict.html

萌无敌 2024-07-29 21:26:23

升级到 Hibernate 3.3.2 或更高版本。

如果您点击链接到生成消息的 错误报告 ,它表明最新版本的 Hibernate(自 3.3.2 起)使用不同的字节码操作包(Javassist),这消除了导致问题的 ASM 冲突。

Upgrade to a Hibernate 3.3.2 or later.

If you follow the link to the bug report that message was generated from, it indicates that the latest versions of Hibernate (since 3.3.2) use a different bytecode manipulation package (Javassist), which eliminates the conflict over ASM which caused the problem.

冰雪梦之恋 2024-07-29 21:26:23

解决方案:ASM 3.1 与 HIbernate 和 JAX-RS 的兼容性问题

  • 删除以下 jar
    1 asm-attrs.jar
    2 asm.jar
    3 cglib-2.1.3.jar

  • 添加以下 jar

1 asm-3.1.jar
2 cglib-nodep-2.1_3.jar

SOLUTION: Compatibility Issue of ASM 3.1 and HIbernate and JAX-RS

  • Remove the following jars
    1 asm-attrs.jar
    2 asm.jar
    3 cglib-2.1.3.jar

  • Add the below jar

1 asm-3.1.jar
2 cglib-nodep-2.1_3.jar

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