brmeyer / HibernateOSGi

14 stars 11 forks source link

Hibernate OSGi - EJB3 #4

Closed lburgazzoli closed 11 years ago

lburgazzoli commented 11 years ago

I've tried to set-up again this example with Hibernate OSGi 4.2.0.Final and I found the following issues:

The persistence provider exported is org.hibernate.ejb.HibernatePersistence whereas it should be org.hibernate.jpa.HibernatePersistenceProvider (IMHO).

Then I've got the following exception when the JPA Container tries to instantiate my JPA bundle:

013-03-28 19:28:52,839 | INFO  | l Console Thread | Console                                    | g.apache.karaf.shell.console.jline.Console  199 | 14 - org.apache.karaf.shell.console - 2.3.0 | Exception caught while executing command
org.apache.karaf.shell.console.MultiException: Error starting bundles:
    Unable to start bundle 58: Activator start error in bundle org.apache.aries.jpa.container [58].
    at org.apache.karaf.shell.console.MultiException.throwIf(MultiException.java:91)
    at org.apache.karaf.shell.osgi.StartBundle.doExecute(StartBundle.java:43)[39:org.apache.karaf.shell.osgi:2.3.0]
    at org.apache.karaf.shell.osgi.BundlesCommand.doExecute(BundlesCommand.java:37)[39:org.apache.karaf.shell.osgi:2.3.0]
    at org.apache.karaf.shell.console.OsgiCommandSupport.execute(OsgiCommandSupport.java:38)[14:org.apache.karaf.shell.console:2.3.0]
    at org.apache.felix.gogo.commands.basic.AbstractCommand.execute(AbstractCommand.java:35)[14:org.apache.karaf.shell.console:2.3.0]
    at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:78)[14:org.apache.karaf.shell.console:2.3.0]
    at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:474)[14:org.apache.karaf.shell.console:2.3.0]
    at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:400)[14:org.apache.karaf.shell.console:2.3.0]
    at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[14:org.apache.karaf.shell.console:2.3.0]
    at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)[14:org.apache.karaf.shell.console:2.3.0]
    at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)[14:org.apache.karaf.shell.console:2.3.0]
    at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)[14:org.apache.karaf.shell.console:2.3.0]
    at org.apache.karaf.shell.console.jline.Console.run(Console.java:175)[14:org.apache.karaf.shell.console:2.3.0]
    at java.lang.Thread.run(Thread.java:722)[:1.7.0_17]
Caused by: java.lang.Exception: Unable to start bundle 58: Activator start error in bundle org.apache.aries.jpa.container [58].
    at org.apache.karaf.shell.osgi.StartBundle.doExecute(StartBundle.java:39)[39:org.apache.karaf.shell.osgi:2.3.0]
    ... 12 more
Caused by: org.osgi.framework.BundleException: Activator start error in bundle org.apache.aries.jpa.container [58].
    at org.apache.felix.framework.Felix.activateBundle(Felix.java:2027)[org.apache.felix.framework-4.0.3.jar:]
    at org.apache.felix.framework.Felix.startBundle(Felix.java:1895)[org.apache.felix.framework-4.0.3.jar:]
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:944)[org.apache.felix.framework-4.0.3.jar:]
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:931)[org.apache.felix.framework-4.0.3.jar:]
    at org.apache.karaf.shell.osgi.StartBundle.doExecute(StartBundle.java:37)[39:org.apache.karaf.shell.osgi:2.3.0]
    ... 12 more
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.ejb.Ejb3Configuration
    at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:90)
    at org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.createEntityManagerFactories(EntityManagerFactoryManager.java:329)
    at org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.registerEntityManagerFactories(EntityManagerFactoryManager.java:242)
    at org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.bundleStateChange(EntityManagerFactoryManager.java:185)
    at org.apache.aries.jpa.container.impl.PersistenceBundleManager.setupManager(PersistenceBundleManager.java:394)
    at org.apache.aries.jpa.container.impl.PersistenceBundleManager.addingBundle(PersistenceBundleManager.java:154)
    at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerAdding(BundleHookBundleTracker.java:185)
    at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerAdding(BundleHookBundleTracker.java:128)
    at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.trackAdding(BundleHookBundleTracker.java:492)
    at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.trackInitial(BundleHookBundleTracker.java:374)
    at org.apache.aries.util.tracker.hook.BundleHookBundleTracker.open(BundleHookBundleTracker.java:81)
    at org.apache.aries.util.tracker.RecursiveBundleTracker.open(RecursiveBundleTracker.java:92)
    at org.apache.aries.jpa.container.impl.PersistenceBundleManager.open(PersistenceBundleManager.java:134)
    at org.apache.aries.jpa.container.impl.PersistenceBundleManager.start(PersistenceBundleManager.java:624)
    at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
    at org.apache.felix.framework.Felix.activateBundle(Felix.java:1977)
    ... 16 more
brmeyer commented 11 years ago

This example was changed yesterday for Hibernate 4.2.1-SNAPSHOT:

https://github.com/brmeyer/HibernateOSGi/commit/c2140ba9cd11aa33521b3a22f673c6313e1b34e8

The snapshot contains big fixes for Hibernate classloaders, etc. See discussions on https://github.com/hibernate/hibernate-orm/pull/486 and https://github.com/hibernate/hibernate-orm/pull/491

org.hibernate.jpa.HibernatePersistenceProvider does not exist in 4.2 -- that's available only in 4.3 (alpha coming next week) and later. org.hibernate.ejb.HibernatePersistence is the only option in 4.2.

Thanks for continuing to work on this. Please give it a try with 4.2.1-SNAPSHOT