-
Mar 14th, 2007, 12:26 AM
#1
AOP and Hibernate Dependency Conflict
spring-aop:2.0.2
hibernate:3.2.1.ga
tomcat:6.0.10
As far as I can tell the conflict I've run into has to do with ASM. I've declared a pointcut and aspect using the new schema based AOP approach. This requires both the spring-aop lib as well as aspectj. I'm applying the aspect to a hibernate dao. During my unit tests the version of asm that hibernate depends on was conflicting with the version spring expected. So, I included asm:2.2.3 and that seemed to work.
However, when deploying to tomcat I get the following cause for an exception:
nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAd visor': Cannot create inner bean '(inner bean)' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name '(inner bean)': Invocation of init method failed; nested exception is java.lang.AbstractMethodError: org.springframework.core.LocalVariableTableParamet erNameDiscoverer$FindMethodParamNamesClassVisitor. visit(ILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String
V
Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAd visor': Cannot create inner bean '(inner bean)' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name '(inner bean)': Invocation of init method failed; nested exception is java.lang.AbstractMethodError: org.springframework.core.LocalVariableTableParamet erNameDiscoverer$FindMethodParamNamesClassVisitor. visit(ILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String
V
Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name '(inner bean)': Invocation of init method failed; nested exception is java.lang.AbstractMethodError: org.springframework.core.LocalVariableTableParamet erNameDiscoverer$FindMethodParamNamesClassVisitor. visit(ILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String
V
Caused by: java.lang.AbstractMethodError: org.springframework.core.LocalVariableTableParamet erNameDiscoverer$FindMethodParamNamesClassVisitor. visit(ILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String
V
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
Considering that I've had to include the newer asm libraries manually I suspect this may have something to do with it. However, Tomcat is the main difference. I'm not sure what to make of this.
Any thoughts are greatly appreciated.
-T
-
Mar 14th, 2007, 07:50 AM
#2
I would try the libs provided by Spring when you download "with dependencies". I have that all working fine!
-
Mar 14th, 2007, 10:22 PM
#3
Okay. I am using maven2. So, I excluded the asm libraries from hibernate. These are asm:1.4.3, -utl, etc. I included the newer asm libraries respecively verion 2.2.3. This works in my AbstractDependencyInjectionSpringContextTests unit tests from Eclipse. Deploying to Tomcat now results in the following error:
...
Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'myTxManager' defined in class path resource [applicationContext-dao.xml]: Cannot resolve reference to bean 'mySessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'mySessionFactory' defined in class path resource [applicationContext-dao.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/objectweb/asm/CodeVisitor
Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'mySessionFactory' defined in class path resource [applicationContext-dao.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/objectweb/asm/CodeVisitor
Caused by: java.lang.NoClassDefFoundError: org/objectweb/asm/CodeVisitor
...
Clearly the txManager requires an older version of asm. However, using the older version of asm breaks the Eclipse unit tests. Also, the older version results in the errors described previously. When deploying the configuration using the older version of asm I get the following error:
...
Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAd visor': Cannot create inner bean '(inner bean)' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name '(inner bean)': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor
Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name '(inner bean)': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor
Caused by: java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor
at org.springframework.aop.aspectj.AbstractAspectJAdv ice.createParameterNameDiscoverer(AbstractAspectJA dvice.java:368)
at org.springframework.aop.aspectj.AbstractAspectJAdv ice.bindArgumentsByName(AbstractAspectJAdvice.java :345)
at org.springframework.aop.aspectj.AbstractAspectJAdv ice.calculateArgumentBindings(AbstractAspectJAdvic e.java:318)
at org.springframework.aop.aspectj.AbstractAspectJAdv ice.afterPropertiesSet(AbstractAspectJAdvice.java: 284)
...
So you see, spring-aop is incompatible with spring-hibernate. Both rely on separate incompatible versions of asm.
I believe this is a major conflict. I do not believe that the apring-aop can be combined with spring-hibernate as they both rely on seperate and incompatible versions of asm.
-
Mar 15th, 2007, 02:24 AM
#4
As a note, I think cglib might have something to do with all this though I've yet to locate the exact relation.
-
Mar 16th, 2007, 01:55 AM
#5
Update. I believe the incompatibility is with the aspectjweaver. It expects asm:2.2.3. Hibernate depends on asm:1.5.3. I can't believe more people haven't encountered this. I'll update this thread as I learn more.
-
Mar 16th, 2007, 02:15 AM
#6
It's hibernate's version of cglib. It expects an older version of asm. I tried just overriding this with the newest cglib, but that caused plenty of other failures. Ugh.
-
Mar 16th, 2007, 02:16 AM
#7
We use Hibernate 3.2.2 together with Spring 2.0.3 and make full use of the Spring 2.0 AOP capabilities. We simply included the ASM version shipped with Spring and everything works without any problems. We also included all the other libraries we needed, like cglib-nodep, we simply used the ones shipped with Spring.
I figure that it has something to do with your build, the error comes from Spring so it appears as if the ASM 1.5.3 library instead of the 2.2.3 version is being included in your build/distribution.
-
Mar 16th, 2007, 02:29 AM
#8
Yes, I know. If you use everything from spring life is grand. It is not possible for this approach to work across all organizations. Many have adopted standardized practices for code development. Mine requires the use of maven not only during development but also during continuous integration (continuum). We've had project after project without error. This particular project I'm working on is making use of spring-aop and the aspectj style in the xml schema. Up until now everything's been great. this throws a wrench in my whole machine. In all likelihood I'll have to resort to using the old aop style as I haven't got much time left and this has taken too much time as it is. Unfortunately this means the old style spring interceptors...it is what it is.
-
Mar 16th, 2007, 02:35 AM
#9
Now that I think of it, that doesn't guarantee that this will work at all. I may have to revert to an earlier version of spring altogether. In either case, its been a nightmare - the type of nightmare that mvn has by and large done away with...at least in my organization.
-
Mar 16th, 2007, 02:37 AM
#10
I haven't worked with maven (1 or 2) but isn't it simply possible to exclude all hibernate referenced libraries and leave just the main hibernate 3.2.x file and use all the needed libraries from the Spring project?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules