开发者

Problem arise while integrate hibernate with restful web service?

开发者 https://www.devze.com 2023-01-10 05:18 出处:网络
I am using hibernate for a while now without any (bigger) problems. Now I am trying to work out RESTful Webservices with project jersey.

I am using hibernate for a while now without any (bigger) problems. Now I am trying to work out RESTful Webservices with project jersey.

It seems that hibernate wich depends on ASM framework (asm.jar, asm-attrs.jar) and jersey which depends on ASM too (asm V3.1 as of asm-3.1.jar) are having problems with the开发者_运维问答 asm implementation versions.

When using asm.jar, jersey is missing a method in org.objectweb.asm.ClassVisitor. When using asm-3.1.jar as of the jersey distribution, hibernate complains about missing class net.sf.cglib.proxy.Enhancer which is provided in cglib-2.1.3.jar.

Both Libraries are using cglib.jar. Thanks and Regards Niladri


I solved this "dependency problem" by switching from cglib to javassist in hibernate

hibernate.properties:
hibernate.bytecode.provider=javassist

and let jersey use cglib.


I use Maven as build tool and I solved the problem by excluding out ASM and instead including "CGLIB No Dependency" dependency.

  <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate</artifactId>
    <version>${hibernate.version}</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>
  <dependency>
    <groupId>cglib</groupId>
    <artifactId>cglib-nodep</artifactId>
    <version>${cglib.version}</version>
  </dependency>
0

精彩评论

暂无评论...
验证码 换一张
取 消