Apr 19th, 2011, 06:04 AM
Hibernate and OSGi integration
I know that there are many post related to this theme, but I couldn't find any simple example
I'm creating spring dynamic bundle which should communicate with database and I decided to use Hibernate as I used it in non OSGI application.
Maybe somebody knows good example how to do that?
At the moment I'm getting error org.hibernate.cfg.Configuration class not found. When I use it in import package the bundle even not compile in eclipse.
Thank you in advance
Apr 26th, 2011, 04:49 PM
If you have placed your hibernate.jar (+ its dependent jars) within your DM bundle's lib directory, it needs to be part of the DM bundle project's 'build path', and 'runtime class path' You cannot import hibernate pkgs through the DM bundle's MANIFEST.MF if your hibernate jars are not OSGi bundles.
To use hibernate in a fully OSGi-ified environment, you would need to repackage hibernate and all its dependencies as OSGi bundles themselves, and make sure they import / export all the right pkgs within their own manifests. This is a non-trivial task: for example, a circular dependency between hibernate and antlr will trip you up. If you use JPA, load-time-weaving issues will take time to sort out.
If I were just starting out with OSGi and Spring DM, I would not try to OSGi-ify hibernate yet. Put the original hibernate jars in the DM project's lib dir, and make sure those jars are on the project's build path and runtime classpath.