Teneo, OSGi and Javaassist for proxy loading


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:

  • org.eclipse.emf.teneo.hibernate.mapping.internal.TeneoInternalEObject
  • javassist.util.proxy.ProxyObject

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.

Advertisements
This entry was posted in Enhanced RCP. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s