2 Replies Latest reply on Dec 11, 2008 3:57 AM by barranek

    Hibernate + MySQL as bundles on Fuse ESB

    barranek

      Hello All,

      Recently I have been playing with Fuse ESB 4.0.0.2 and with application that uses Hibernate for connecting to MySQL server.

      I have deployed Hibernate libraries and MySQL connector as bundles and they seem to work. However, my application throws following exception when it is trying to connect to database:

       

      14:43:07,177 | WARN  | Timer-1          | FileMonitor                      | x.kernel.filemonitor.FileMonitor  558 | Failed to start bundle: org.escapek.osgi.hibernate . Reason: org.osgi.framework.BundleException: Activator start error.

      org.osgi.framework.BundleException: Activator start error.

          at org.apache.felix.framework.Felix._startBundle(Felix.java:1651)

          at org.apache.felix.framework.Felix.startBundle(Felix.java:1541)

          at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:371)

          at org.apache.servicemix.kernel.filemonitor.FileMonitor.refreshPackagesAndStartOrUpdateBundles(FileMonitor.java:554)

          at org.apache.servicemix.kernel.filemonitor.FileMonitor.onFilesChanged(FileMonitor.java:301)

          at org.apache.servicemix.kernel.filemonitor.FileMonitor$1.filesChanged(FileMonitor.java:146)

          at org.apache.servicemix.kernel.filemonitor.Scanner.reportBulkChanges(Scanner.java:433)

          at org.apache.servicemix.kernel.filemonitor.Scanner.reportDifferences(Scanner.java:322)

          at org.apache.servicemix.kernel.filemonitor.Scanner.scan(Scanner.java:254)

          at org.apache.servicemix.kernel.filemonitor.Scanner$1.run(Scanner.java:214)

          at java.util.TimerThread.mainLoop(Timer.java:512)

          at java.util.TimerThread.run(Timer.java:462)

      Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.mysql.jdbc.ConnectionImpl

          at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)

          at java.sql.DriverManager.getConnection(DriverManager.java:582)

          at java.sql.DriverManager.getConnection(DriverManager.java:154)

          at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)

          at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:84)

          at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2073)

          at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1298)

          at com.swmind.osgi.tutorial.InitSessionFactory.initSessionFactory(InitSessionFactory.java:100)

          at com.swmind.osgi.tutorial.InitSessionFactory.getInstance(InitSessionFactory.java:44)

          at com.swmind.osgi.tutorial.TestExample.createHoney(TestExample.java:80)

          at com.swmind.osgi.tutorial.TestExample.doStuff(TestExample.java:33)

          at com.swmind.osgi.tutorial.impl.Activator.start(Activator.java:38)

          at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:591)

          at org.apache.felix.framework.Felix._startBundle(Felix.java:1607)

       

      Does anyone knows what's happening?

       

      Thanks in advance,

       

      Lukasz Baran

        • 1. Re: Hibernate + MySQL as bundles on Fuse ESB
          lhein

          Are you sure that you have bundled the libs correctly?

          I mean you need to check the manifest of the bundles jar file to be sure

          that they are in a OSGi bundle format.

           

          Regards

          Lars

          • 2. Re: Hibernate + MySQL as bundles on Fuse ESB
            barranek

            Thank you for the answer.

            And yes, of course, MANIFEST files are correct. The problem seems to be in the visibility of com.mysql.jdbc.ConnectionImpl package.

             

            I've organized my code in to bundles - one of the contains Hibernate classes, the second ones contains mapped entities, MySQL driver i Hibernate configuration.

             

            Of course, I have properly defined Import-Package and Export-Package sections. However, the problem still exists:(

            I'll try to embed driver classes in hibernate bundle. Maybe it will help...

            Regards,

            Lukasz