Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-3856

Jar incompatibility: Hibernate 3.2.5GA requires asm 1.5.3 and Spring 2.1M3 requires asm 2.2.3

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.1 M3
    • Fix Version/s: 2.5 RC1
    • Component/s: Core
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      See http://opensource.atlassian.com/projects/hibernate/browse/HHH-2222

      It was answered in the post
      http://forum.springframework.org/showthread.php?t=18124
      However the solution provided doesnt work for me, also I dont see how it would work, the version in the dependencies in the hibernate pom and in the spring pom are different. Its not a problem due to including a jar by mistake.

      I tried to solve the problem by trying to force hibernate to use the spring version of the asm jar:

      Here are the steps I tried in the pom

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

      <!--
      Dependency added to fix:

      Caused by: java.lang.NoClassDefFoundError: org/objectweb/asm/commons/EmptyVisitor
      at java.lang.ClassLoader.defineClass1(Native Method)
      ...
      at org.springframework.core.type.filter.AnnotationTypeFilter.matchSelf(AnnotationTypeFilter.java:52)
      at org.springframework.core.type.filter.AbstractTypeHierarchyTraversingFilter.match(AbstractTypeHierarchyTraversingFilter.java:
      54)
      at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.isCandidateComponent(ClassPathScanningCan
      didateComponentProvider.java:183)
      at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.getClassReaderIfCandidate(ClassPathScanni
      ngCandidateComponentProvider.java:166)
      ...
      -->
      <dependency>
      <groupId>asm</groupId>
      <artifactId>asm-commons</artifactId>
      <version>2.2.3</version>
      </dependency>

      <!--
      Fix error: asm version 2.0 +
      Caused by: java.lang.NoClassDefFoundError: org/objectweb/asm/FieldVisitor
      ...
      at org.springframework.core.type.filter.AnnotationTypeFilter.matchSelf(AnnotationTypeFilter.java:52)
      at org.springframework.core.type.filter.AbstractTypeHierarchyTraversingFilter.match(AbstractTypeHierarchyTraversingFilter.java:
      54)
      at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.isCandidateComponent(ClassPathScanningCan
      didateComponentProvider.java:183)

      -->

      <!--
      Fixing this gives
      Caused by: java.lang.NoClassDefFoundError: org/objectweb/asm/CodeVisitor
      at net.sf.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:165)
      at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
      at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
      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.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69)
      at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:117)
      at org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:43)
      at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:162)

      Code Visitor is in asm 1.5.3 or before

      Then an exception that a method doesnt exist ...

      There are several web pages that document the fact (including a patch to hibernate (which isnt implemented)

      http://blog.interface21.com/main/2007/06/11/asm-version-incompatibilities-using-spring-autowired-with-hibernate/

      http://blog.interface21.com/main/2007/06/11/asm-version-incompatibilities-using-spring-autowired-with-hibernate/feed/

      http://opensource.atlassian.com/projects/hibernate/browse/HHH-2222

      http://forum.springframework.org/showthread.php?p=127012#poststop

      The solution seems to be: create a fork of the asm project, changing the package name, and recompile the spring source with that version.
      The asm developers really should do that anyway if they break the compatibility at each change in the VM.
      I know its not the ideal solution, but I cant think of a better one.

      Or could you explain how to run hibernate on a different class loader to spring inside tomcat?

      i tried to get hibernate to use javassist but that didnt cure the problem.

      I would have used OSGi but there doesnt seem to be a hibernate implementation just yet.

      Hope you can provide a fix soon, its a major showstopper for me.

        Attachments

          Activity

            People

            • Assignee:
              juergen.hoeller Juergen Hoeller
              Reporter:
              hazlorealidad Andrew Bailey
              Last updater:
              Spring Issuemaster
            • Votes:
              2 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                26 weeks, 4 days ago