Yesterday I’ve debugged to get javaassist working with teneo which gave us headaches in the past so we simply turned it off which isn’t really a problem to us but I simply wanted to know why it didn’t worked.
As very often when hibernate and OSGi meet each other this is a problem of classloading and class-visibility.
A normal bundle layout for a Teneo-Hibernate application looks like this:
- org.my.model: Holds your EMF-Model
- org.hibernate: Holds the hibernate libraries with its dependencies (one of them is javassist)
- org.eclipse.emf.teneo.hibernate: The Teneo Hibernate integration
The problem is that the classloader used by javaassist is the BundleClassLoader from org.my.model so from there it needs to look up 2 other important classes when it comes to proxy creation:
The first one you can fix by adding org.eclipse.emf.teneo.hibernate as an optional depdency on your org.my.model not really nice but well it is the only possibility.
The second one is similar but the solution is even worse because it is NOT sufficient to add org.hibernate as a required bundle because the Bundle-Classloader will not know that org.hibernate provides javassist.util.proxy because org.hibernate doesn’t export it.
So the only solution I found was to import the org.hibernate bundle coming shipped by Martin Taal from elver.org and add the exports in question.