Why Spring and Hibernate cant be seperated

27 12 2007

After extracting the spring-core, spring-hibernate3 and all the various parts of Sakai, fixing the classloader issues surrounding IdGenerators etc, I find both Spring and Hibernate use CG Lib for proxies, and if you separate Spring from Hibernate, they fight over CGLib. Either Hibernate cant create proxies because it cant see the hibernate classes from CGLib or Spring cant get to CGLib because its not in shared. Looks like its not going to be possible to separate Spring and Hibernate into separate classloaders without providing some extra level of visibility between the classloaders.



One response

28 12 2007
Ian Boston

However, its now possible to switch the reflection library to javassist in H 3.2.5ga, you cant do it through the spring injected properties, but if you have a hibernate.properties in the class path containing, “hibernate.bytecode.provider=javassist” you can switch from CGLib to Javaassist just for hibernate…. but that now opens another problem, antlr, both Spring and Hibernate use Antlr… same problem different lib. Antlr is using the context classloader to do its work, but this is the shared classloader which cant see hibernate, so cant load anything. Since all of this is at startup, it may be worth looking at the proper separation between each Spring context so that the correct context classloader can be used.

%d bloggers like this: