Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jar incompatibility: Hibernate 3.2.5GA requires asm 1.5.3 and Spring 2.1M3 requires asm 2.2.3 [SPR-3856] #8536

Closed
spring-issuemaster opened this issue Sep 9, 2007 · 14 comments

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

commented Sep 9, 2007

Andrew Bailey opened SPR-3856 and commented

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:
    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.


Affects: 2.1 M3

2 votes, 6 watchers

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 9, 2007

Andrew Bailey commented

I forgot to mention that it is a know issue, the report: http://opensource.atlassian.com/projects/spring/browse/OSGI-155
states:
The spring-core module currently does not specify a version for the import of the org.objectweb.asm* packages. Since asm v1 is binary incompatible with v2 this can cause a problem. Some other projects (e.g. hibernate) require the v1 version while Spring requires the v2 version.

(I dont understand how the proposed solution would fix it if hibernate and spring are loaded by the same classloader)

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 10, 2007

Ben Speakmon commented

It wouldn't fix it -- they depend on mutually incompatible bytecode under the same package. I'm not an OSGi wizard, but personally I'd rather take care of a problem like this myself.

The only way to make this work is to apply the patch I submitted to HHH-2222 and run Spring and Hibernate with cglib-nodep (which repackages ASM 1.5.3). It's not a big change, and Hibernate could easily fix it if they wanted to. There isn't really anything Spring can do about this, since they already use cglib-nodep for their ASM 1.5.3 needs.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 10, 2007

Andrew Bailey commented

It would be good that the hibernate team changed it but as they havent done so since the patch sent in May of this year, are they likely to do it? What other solutions are there?

I dont see why the solution I proposed in my first email wouldnt work :

"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. "

  • a quick refactor of the asm project and spring-core in eclipse with the change of the package asm -> asm223 should work.

the only problem is that there would be a non standard asm jarfile
but 30 minutes work beats waiting another 5 months
also thats exactly whats in the cglib jar a repackaged asm lib in a different package.

I would do it but I dont fancy a custom built spring framework to maintain.

Or maybe in the jar manifest we could put a version number of the jar and then specify its dependencies and then write a custom class loader that always loads the right version of a class from the jar thats configured for that code!
(just joking - unless a Sun Executive is reading this)
(in any case its probably what OSGi does under the hood.)

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 18, 2007

Andrew Bailey commented

I just noticed that the asm faq has the solution http://asm.objectweb.org/doc/faq.html

15 How to resolve conflicts between different ASM API versions available in a global classpath or within the same ClassLoader?

Tools and frameworks that are using ASM for bytecode processing (e.g. Hibernate, CGLIB, AspectWerkz) should repackage ASM code within their own name space. This can be automated with Jar Jar Links tool. http://tonicsystems.com/products/jarjar/


Jar Jar Links is a utility that makes it easy to repackage Java libraries and embed them into your own distribution. This is useful for two reasons:

* You can easily ship a single jar file with no external dependencies.
* You can avoid problems where your library depends on a specific version of a library, which may conflict with the dependencies of another library.

...
Jar Jar Links includes an Ant task (com.tonicsystems.jarjar.JarJarTask) that extends the built-in Jar task. The normal zipfileset element is used to embed jar files. A new rule element is added which uses wildcards patterns to rename the embedded class files. Bytecode transformation (via ASM) is used to change references to the renamed classes, and special handling is provided for moving resource files and transforming string literals.

Jar Jar Friendly Libraries: include ASM

... so it doesnt seem like any source code changes are needed !

Hope its possible to implement this soon.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 20, 2007

Juergen Hoeller commented

We're using Hibernate with the cglib-nodep.jar, with the standard asm jars used for Spring's own purposes. As far as I understand, the conflict only arises when using separate cglib and asm jars instead of cglib-nodep? Is there a reason why you can't simply use cglib-nodep in your application builds, no matter what the Hibernate distribution looks like? I'm not sure what Hibernate would have to 'fix' there... Using cglib-nodep is completely up to you and has been working with Hibernate for years.

That said, I'm open to repackaging the ASM version that Spring uses. The unfortunate part there is that ASM is optional for those purposes; Spring only uses ASM for specific features (such as component scanning). Including a repackaged ASM version will increase the size of spring-core.jar by 85 KB - and that only for an optional feature... I guess we could ship a separate spring-asm.jar with only the repackaged ASM version, but that would have to be maintained as a dedicated module (uploaded to ibiblio etc), updated along with new ASM versions, etc. Quite a bit of effort for a purely optional feature...

Juergen

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 27, 2007

Andrew Bailey commented

I apologize in advance that the following stack traces dont explain what the situation is (they are copied and pasted from the server logs)
and I dont have a record of exactly what I tried at what time.

Basically I changed asm versions or left out the asm jar
if I used one version of the asm lib the ClassPathScanner wouldnt have the right version
and if I used another hibernate wouldnt have the right version!

I dont think cglib-nodep is the cause/solution as the asm lib was repackaged as net.sf.cglib.asm in the cglib-nodep jar
and that package isnt the problem in the stack traces.

I think the problem is that the ClassPathScanner uses the org.objectweb.asm package and so does hibernate but that they need 2 different versions.

I know you say its optional but it would be great to use hibernate and more sophisticated spring features together.

I hope you can see the problem from the traces.

Thanks in advance
any suggestion for a solution would be appreciated

Andy


Trace1:

nested exception is java.lang.NoClassDefFoundError: org/object
web/asm/ClassVisitor
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadB
eanDefinitions(XmlBeanDefinitionReader.java:375)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBea
nDefinitions(XmlBeanDefinitionReader.java:303)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBea
nDefinitions(XmlBeanDefinitionReader.java:280)
.
.
Caused by: java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor
at org.springframework.context.annotation.ClassPathScanningCandidateComp
onentProvider.registerDefaultFilters(ClassPathScanningCandidateComponentProvider
.java:130)
at org.springframework.context.annotation.ClassPathScanningCandidateComp
onentProvider.<init>(ClassPathScanningCandidateComponentProvider.java:77)
at org.springframework.context.annotation.ClassPathBeanDefinitionScanner
.<init>(ClassPathBeanDefinitionScanner.java:80)
at org.springframework.context.annotation.ComponentScanBeanDefinitionPar
ser.parse(ComponentScanBeanDefinitionParser.java:85)
at org.springframework.beans.factory.xml.Namespace


Trace2:

Invocation of init method failed; nested exception is java.lang.N
oClassDefFoundError: org/objectweb/asm/CodeVisitor
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:534)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:246)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:166)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:243)
.------------------------------
Trace3:

Invocation of init method failed; nested
exception is java.lang.NoClassDefFoundError: org/objectweb/asm/CodeVisitor
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1282)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:510)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:246)
.
.
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(DefaultGeneratorS
trategy.java:25)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerato
r.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(C
GLIBLazyInitializer.java:117)
at org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.postInstantiate(CGLI
BProxyFactory.java:43)
at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(Po
joE
ntityTuplizer.java:162)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEnti
tyTuplizer.java:135)
at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTupliz
er.java:55)
at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(E
ntityEntityModeToTuplizerMapping.java:56)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.jav
a:295)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(Abstrac
tEntityPersister.java:434)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(Sing
leTableEntityPersister.java:109)
at org.hibernate.persister.PersisterFactory.createClassPersister(Persist
erFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:
226)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.jav
a:1294)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Con
figuration.java:713)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFa
ctory(HibernatePersistence.java:127)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.cr
eateNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPro
pertiesSet(AbstractEntityManagerFactoryBean.java:251)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1310)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1279)


Trace4:

java.lang.NoClassDefFoundError: org/object
web/asm/commons/EmptyVisitor
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadB
eanDefinitions(XmlBeanDefinitionReader.java:375)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBea
nDefinitions(XmlBeanDefinitionReader.java:303)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBea
nDefinitions(XmlBeanDefinitionReader.java:280)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReade
r.loadBeanDefinitions(AbstractBeanDefinitionReader.java:142)
.
.
Caused by: java.lang.NoClassDefFoundError: org/objectweb/asm/commons/EmptyVisito
r
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
4)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(Webapp
ClassLoader.java:1817)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoa
der.java:872)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
der.java:1325)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
der.java:1204)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
4)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(Webapp
ClassLoader.java:1817)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoa
der.java:872)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
der.java:1325)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
der.java:1204)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at org.springframework.core.type.filter.AnnotationTypeFilter.matchSelf(A
nnotationTypeFilter.java:52)
at org.springframework.core.type.filter.AbstractTypeHierarchyTraversingF
ilter.match(AbstractTypeHierarchyTraversingFilter.java:54)
at org.springframework.context.annotation.ClassPathScanningCandidateComp
onentProvider.isCandidateComponent(ClassPathScanningCandidateComponentProvider.j
ava:183)
at org.springframework.context.annotation.ClassPathScanningCandidateComp
onentProvider.getClassReaderIfCandidate(ClassPathScanningCandidateComponentProvi
der.java:166)
at org.springframework.context.annotation.ClassPathScanningCandidateComp
onentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvide
r.java:148)
at org.springframework.context.annotation.ClassPathBeanDefinitionScanner
.doScan(ClassPathBeanDefinitionScanner.java:159)
at org.springframework.context.annotation.ComponentScanBeanDefinitionPar
ser.parse(ComponentScanBeanDefinitionParser.java:145)


Trace5:

nested exception is java.lang.NoClassDefFoundError: org/object
web/asm/FieldVisitor
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadB
eanDefinitions(XmlBeanDefinitionReader.java:375)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBea
nDefinitions(XmlBeanDefinitionReader.java:303)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBea
nDefinitions(XmlBeanDefinitionReader.java:280)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReade
r.loadBeanDefinitions(AbstractBeanDefinitionReader.java:142)
.
.
Caused by: java.lang.NoClassDefFoundError: org/objectweb/asm/FieldVisitor
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
4)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(Webapp
ClassLoader.java:1817)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoa
der.java:872)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
der.java:1325)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
der.java:1204)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
4)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(Webapp
ClassLoader.java:1817)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoa
der.java:872)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
der.java:1325)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
der.java:1204)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
4)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(Webapp
ClassLoader.java:1817)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoa
der.java:872)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
der.java:1325)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
der.java:1204)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at org.springframework.core.type.filter.AnnotationTypeFilter.matchSelf(A
nnotationTypeFilter.java:52)
at org.springframework.core.type.filter.AbstractTypeHierarchyTraversingF
ilter.match(AbstractTypeHierarchyTraversingFilter.java:54)
at org.springframework.context.annotation.ClassPathScanningCandidateComp
onentProvider.isCandidateComponent(ClassPathScanningCandidateComponentProvider


Trace6:

Invocation of init method failed; nested exception is java.lang.N
oSuchMethodError: org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava
/lang/String;[Ljava/lang/String;Ljava/lang/String;)V
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:534)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:246)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:166)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:243)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:167)
.
.
.
Caused by: java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit(IIL
java/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V
at net.sf.cglib.core.ClassEmitter.begin_class(ClassEmitter.java:77)
at net.sf.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:
173)
at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorS
trategy.java:25)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerato
r.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(C
GLIBLazyInitializer.java:117)
at org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.postInstantiate(CGLI
BProxyFactory.java:43)
at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoE
ntityTuplizer.java:162)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEnti
tyTuplizer.java:135)
at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTupliz
er.java:55)
at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(E
ntityEntityModeToTuplizerMapping.java:56)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.jav
a:295)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(Abstrac
tEntityPersister.java:434)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(Sing
leTableEntityPersister.java:109)
at org.hibernate.persister.PersisterFactory.createClassPersister(Persist
erFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:
226)


@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 27, 2007

Juergen Hoeller commented

As far as I'm aware, Hibernate is NOT using ASM directly - it's only using ASM through CGLIB. So if you use the cglib-nodep.jar, Hibernate should not talk to ASM natively at all. Which means that the native ASM jar can be the one that Spring requires, without any conflicts.

So if you have:

  • cglib-nodep-2.1_3.jar
  • asm-2.2.3.jar
  • asm-commons-2.2.3.jar
  • asm-util-2.2.3.jar

and no other CGLIB or ASM jars on your classpath, things should work fine with Spring and Hibernate on top.

Juergen

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 27, 2007

Ben Speakmon commented

Juergen,

I did the patch referenced in HHH-2222 and Hibernate unfortunately does depend directly on ASM 1.5.3:

src/org/hibernate/bytecode/cglib/CglibClassTransformer.java
src/org/hibernate/bytecode/cglib/BytecodeProviderImpl.java
src/org/hibernate/tool/instrument/cglib/InstrumentTask.java

And in my testing I've proven that Hibernate won't run with Spring's 2.2.3 ASM dependency.

However, it is a Hibernate problem, and I'm not sure what you guys could do to fix it. People in Andrew's situation will have to patch Hibernate themselves or avoid using any part of Spring that requires ASM.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 27, 2007

Juergen Hoeller commented

Ouch, that's pretty bad - I wasn't aware of this. We're running our PetClinic Hibernate version with cglib and asm-2.2.3 on the classpath and it seems to work just fine... Puzzling.

In any case, we do intend to repackage ASM for Spring's purposes for 2.5 RC1. This is all we can do from Spring's side.

Juergen

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 27, 2007

Ben Speakmon commented

We have a Hibernate committer on staff here -- I'll talk to her and see if we can get the patch into Hibernate. That'll solve your problem for you :)

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 27, 2007

Andrew Bailey commented

Wow, you guys work fast!

So if I understand the situation I cant use things like the ClassPathScanner with hibernate until spring 2.5RC1 (unless I run a custom version of hibernate/spring (which Im not about to do!))

There is one thing that puzzles me, the application in eclipse worked but then failed in tomcat, something to do with OSGi and eclipses classloading?

By the way I would like to move to OSGi for my spring applications and have played around with spring OSGi, would this help in this instance?

Thanks for the help.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Oct 2, 2007

Ben Speakmon commented

Per HHH-2222, the Hibernate guys are dead set against repackaging their use of ASM 1.x. However, it seems they won't release 3.2.6 until cglib 2.2 (which repackages ASM 2.2.1) is ready. If ASM 2.2.1 and ASM 2.2.3 are binary compatible, this problem will go away for good.

For now, though, the options are to either apply HHH-2222 to your copy of Hibernate or use javassist as Hibernate's bytecode provider.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Oct 9, 2007

Juergen Hoeller commented

We do repackage ASM for Spring 2.5 now (as part of spring.jar and spring-core.jar), avoiding conflicts with other ASM versions as well as making it easier to use Spring's component scanning feature (no need for adding any asm-* jars for those purposes anymore).

This required a revision of Spring's "core.type" package, using ASM internally now, with no ASM artifacts exposed publically - meaning that other packages (other Spring framework packages as well as third-party packages) can use "core.type" without being tied to the original or repackaged ASM location.

Juergen

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Oct 12, 2007

Andrew Bailey commented

Excellent, thanks very much.

I know its not a jira issue but I cant find Spring 2.5 in any maven repository, as I understood the snapshots should be in
http://s3browse.com/explore/maven.springframework.org/snapshot/org/springframework/
(I also looked in http://s3browse.com/explore/maven.springframework.org/milestone/org/springframework/spring-core/)
when will it get uploaded?
It would be great to test it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.