I was working on Spring 2.1 stuff this week with Joris. We were preparing a sample using all three ways of doing dependency injection. The sample does not only highlight dependency injection, but also features a back-end based on Hibernate.
Several features in Spring 2.1 require the ASM byte code manipulation framework. Hibernate also uses ASM, through CGLIB. There is a binary incompatibility between ASM 1.5.3 and 2.2.3. The former is used by Hibernate, the latter is used by Spring in various scenarios; specifically in some of the AOP functionality and the new @Autowired features.
UPDATE: read solution number 3 first!
Solution no. 1
The first solution is to explicitly replace the CGLIB jar for Hibernate with a nodep version (one is available from the Spring distribution) which contains a re-packaged version of ASM version 1.5.3. With Maven, this requires you to put in a few exclusions alongside your Hibernate dependency and to explicitly put in the ASM 2.2.3 dependency in your pom.
<dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate</artifactId> <version>3.2.1.ga</version> <exclusions> <exclusion> <groupId>asm</groupId> <artifactId>asm</artifactId> </exclusion> <exclusion> <groupId>asm</groupId> <artifactId>asm-attrs</artifactId> </exclusion> </exclusions> </dependency>
<dependency> <groupId>asm</groupId> <artifactId>asm</artifactId> <version>2.2.3</version> </dependency>
Solution no. 2
Solution no.3 (added October 18 2007)
As of Spring 2.5rc1, spring.jar contains ASM 2.2.3 (repackaged using Jar Jar Links (that name!!!!! ). This means all incompatibilities with other projects using ASM should from now on be a thing of the past. I haven't tried this out yet, so you should figure this one out for yourself.
- Migrating to Spring 3.1 and Hibernate 4.1
- Spring Framework 3.2 RC1 released
- Maven PAR Plugin 1.0.0.M1
- Reuse your Hibernate/JPA domain model with Grails
- Spring Framework 3.0.2 released