Issue Details (XML | Word | Printable)

Key: SPR-3856
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Juergen Hoeller
Reporter: Andrew Bailey
Votes: 2
Watchers: 6
Operations

If you were logged in you would be able to see more operations.
Spring Framework

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

Created: 09/Sep/07 11:39 PM   Updated: 12/Oct/07 10:45 AM   Resolved: 09/Oct/07 08:56 AM
Component/s: SpringCORE
Affects Version/s: 2.1 M3
Fix Version/s: 2.5 RC1

Time Tracking:
Not Specified

Environment: All platforms (Running inside eclipse works) however running a test case in maven or deploying to tomcat produces the error

Virtual Machine: Sun JVM - 1.5
Platform: Standalone


 Description  « Hide

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.



Juergen Hoeller made changes - 10/Sep/07 06:41 AM
Field Original Value New Value
Fix Version/s 2.1 RC1 [ 10550 ]
Assignee Juergen Hoeller [ juergen.hoeller ]
Juergen Hoeller made changes - 09/Oct/07 08:56 AM
Status Open [ 1 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]