When using both spring and hibernate, I ran into some rather difficult to debug problems caused by each product using different versions of the same class files. Since the first class file loaded prevents another class file of the same type being loaded, this led to unpredictable behavior. In particular, I would have it running fine from my IDE, but not from ant. When I finally got it running from ant, it stopped working in the IDE. On the theory that the order in which the jar files were loaded was the difference between ant and my IDE, I wrote a program to scan all the class files in all the jars, and tell me which classes conflicted.
The class in particular that was causing me grief was org.objectweb.asm.ClassVisitor. In spring, this was in lib/asm/asm-2.2.2.jar, in hibernate, this was in lib/asm.jar. Simply deleting asm-2.2.2.jar fixed my problem, but it got me thinking that my fix was more luck than a reliable solution. By deleting the spring version to get hibernate working, I risk breaking spring.
Does anyone know of any work/research related to solving the problem where two separate libraries depend on two different versions of the same class file? Seems like a difficult problem that is inevitable when using many open source libraries. It would be nice if I could get the spring methods to call the spring version and the hibernate methods to call the hibernate version, but the JVM is just not built this way.
Spring version: 2.0-rc3
Hibernate version: 3.2.0.cr2
Sean Shubin


Reply With Quote