2 Replies Latest reply on Aug 24, 2012 3:02 AM by davsclaus

    How to resolve dependencies related to hibernate in Fuse ESB.

    sarfarajsayyad

      I am not able to get the db operations working using hibernate in Fuse ESB. I am using oracle database and reading from the database table in the camel-context route using hibernate.

       

      Actually when I run the camel-context locally from Fuse IDE, the db operations work, but when I bundle the project and deploy it in Fuse ESB I am unable to resolve the dependencies related to hibernate.

       

      Installing the project bundle into Fuse ESB gives following dependency errors related to hibernate:

      1. Class not found - org/hibernate/ejb/HibernatePersistence

         To fix this I installed hibernate-entitymanager-3.6.2.Final.jar, I bundled the jar using bnd tool and then  installed it in servicemix. I also put in this package under <Importe-Package> in bundle plugin in my project pom.xml.  This resolved the dependency error .

      2. Next error is Class not found - org/hibernate/MappingException

         For this I can install either hibernate-core-3.6.2.Final or hibernate-3.6.2.Final ( aggregate jar).

         But when I install any of these jars the hibernate-entitymanager installed in (1) above fails saying that it exports org.hibernate.engine which is also exported by hibernate-core.

       

      How can I solve this error ? Actually most of the hibernate jars have duplicate packages in them.

         For e.g.

         hibernate-core, hibernate and hibernate-entitymanager having org.hibernate.engine.

         Also org.hibernate.annotations package is present in multiple jars.

       

      How can these jars co-exists in Fuse ESB if I need to install all of them? How can I get this dependency resolved ?

        • 1. Re: How to resolve dependencies related to hibernate in Fuse ESB.
          ffang

          Hi,

           

          I'd say make hibernate work in OSGi container isn't an easy task.

           

          Split-package issue everywhere is one reason, but still have other reasons like classloader issue.

           

          You have to repackage hibernate lib yourself or use some 3rd party lib which repackage hibernate lib.

           

          FUSE ESB 4.x has a jpa-osgi example shipped with kit, you may need take a look, it use hibernate libs packaged by springsource.

           

          We've also built higher version of hibernate lib to make it works in OSGi container, but it's not free, if you have fuse subscription you can use that channel to contact.

           

          Btw, if you can change the JPA implementation then you can try with openjpa, it works better in OSGi container.

           

          Freeman

          • 2. Re: How to resolve dependencies related to hibernate in Fuse ESB.
            davsclaus

            You may also want to look at FAB that makes deployment applications to the OSGi container much much easier

             

            I posted a blog with some links for material with video introductions, further documentations, and examples

            http://www.davsclaus.com/2012/08/osgi-deployment-made-easy-with-fab.html

             

            Deploying and using Hibernate should then become much easier. The other day a person leverage this to get his Hibernate working.