Apache Felix 中的 JPA / Hibernate 集成
Posted
技术标签:
【中文标题】Apache Felix 中的 JPA / Hibernate 集成【英文标题】:JPA / Hibernate integration in Apache Felix 【发布时间】:2014-09-09 00:51:26 【问题描述】:您好,我运行一个嵌入在 tomcat 中的 apache Felix 实例。我需要 JPA(Hibernate 4.2.7 实现)集成,但在创建 EntityManagerFactory 时出现此异常。 作为记录,如果我切换到 OpenJPA 一切正常,但这个解决方案是不可接受的
我有两个包:
dbconnection-ds: blueprint.xml
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd"
xmlns:jpa="http://aries.apache.org/xmlns/jpa/v1.0.0"
xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.1.0"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0">
<!-- BASIC CONFIGURATION -->
<bean id="dataSource" class="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource">
<property name="url" value="jdbc:mysql://127.0.0.1:3306/test"/>
<property name="user" value="root"/>
<property name="password" value=""/>
</bean>
<service interface="javax.sql.XADataSource" ref="dataSource">
<service-properties>
<entry key="osgi.jndi.service.name" value="jdbc/test"/>
</service-properties>
</service>
</blueprint>
dbconnection:blueprint.xml
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd"
xmlns:jpa="http://aries.apache.org/xmlns/jpa/v1.0.0"
xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.1.0"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0">
<bean id="dbService" class="examples.DBService">
<jpa:context property="em" unitname="testPU" />
<tx:transaction method="*" value="Required"/>
</bean>
<service ref="dbService" interface="examples.IDBService" >
<service-properties>
<entry key ="osgi.jndi.service.name"
value="hibernate/dbService"/>
</service-properties>
</service>
</blueprint>
dbconnection:perisitence.xml
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="2.0">
<persistence-unit name="testPU" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>osgi:service/javax.sql.XADataSource/(osgi.jndi.service.name=jdbc/test)</jta-data-source>
<properties>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
<property name="hibernate.connection.url" value="jdbc:mysql://127.0.0.1:3306/test" />
</properties>
</persistence-unit>
</persistence>
这是我的堆栈跟踪
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.apache.felix.framework.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.apache.aries.jndi.url.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.hibernate.osgi.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: classmate.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.apache.felix.fileinstall.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.apache.aries.jpa.blueprint.aries.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.apache.servicemix.bundles.serp.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.apache.aries.proxy.impl.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.apache.geronimo.specs.geronimo-jta_1.1_spec.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: null.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: com.fasterxml.jackson.core.jackson-databind.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.apache.aries.blueprint.api.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.apache.karaf.jndi.core.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.apache.felix.shell.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.apache.servicemix.bundles.antlr.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.apache.aries.jpa.container.context.
INFO | main | o.a.a.j.c.context | - - | No quiesce support is available, so managed persistence units will not participate in quiesce operations.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.hibernate.common.hibernate-commons-annotations.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.apache.felix.shell.remote.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.apache.aries.util.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.jboss.spec.javax.security.jacc.jboss-jacc-api_1.4_spec.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.apache.aries.blueprint.core.
INFO | main | o.a.a.b.c.BlueprintExtender | - - | No quiesce support is available, so blueprint components will not participate in quiesce operations
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: com.fasterxml.jackson.core.jackson-core.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.apache.geronimo.specs.geronimo-jpa_2.0_spec.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: javassist.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: com.springsource.org.apache.catalina.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.apache.aries.jndi.api.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.apache.felix.configadmin.
DEBUG | rint Extender: 1 | o.a.a.j.b.aries | - - | Managed persistence context support is now available for use with the Aries Blueprint container
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.apache.aries.jndi.legacy.support.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.apache.aries.jndi.rmi.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.apache.felix.log.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.jboss.logging.jboss-logging.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.apache.aries.blueprint.cm.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.apache.aries.proxy.api.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.apache.aries.proxy.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.apache.aries.transaction.blueprint.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.apache.servicemix.bundles.dom4j.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.apache.xbean.naming.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.apache.servicemix.bundles.ant.
INFO | rint Extender: 1 | o.a.a.b.c.BlueprintContainerImpl | - - | Bundle org.apache.aries.transaction.blueprint is waiting for dependencies [(objectClass=javax.transaction.TransactionManager)]
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.apache.aries.jpa.api.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: com.fasterxml.jackson.core.jackson-annotations.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.apache.aries.transaction.manager.
INFO | main | o.a.a.j.c.context | - - | A TransactionSynchronizationRegistry service is now available in the runtime. Managed persistence contexts will now integrate with JTA transactions using [org.apache.aries.transaction.AriesTransactionManager, javax.transaction.TransactionManager, javax.transaction.TransactionSynchronizationRegistry, javax.transaction.UserTransaction, org.apache.geronimo.transaction.manager.RecoverableTransactionManager].
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.hibernate.core.
WARN | es.transaction]) | o.a.a.j.c.context | - - | The TransactionSynchronizationRegistry used to manage persistence contexts is no longer available. Managed persistence contexts will no longer be able to integrate with JTA transactions, and will behave as if no there is no transaction context at all times until a new TransactionSynchronizationRegistry is available. Applications using managed persistence contexts may not work correctly until a new JTA Transaction services implementation is available.
INFO | es.transaction]) | o.a.a.j.c.context | - - | A TransactionSynchronizationRegistry service is now available in the runtime. Managed persistence contexts will now integrate with JTA transactions using [org.apache.aries.transaction.AriesTransactionManager, javax.transaction.TransactionManager, javax.transaction.TransactionSynchronizationRegistry, javax.transaction.UserTransaction, org.apache.geronimo.transaction.manager.RecoverableTransactionManager].
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.apache.aries.jndi.core.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.hibernate.entitymanager.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | Starting bundle: org.apache.aries.jpa.container.
INFO | main | o.a.a.j.container | - - | The file org.apache.aries.jpa.container.properties was not found in bundle org.apache.aries.jpa.container/1.0.1.SNAPSHOT. The default properties will be used.
DEBUG | main | o.a.a.j.container | - - | Adding a provider: [javax.persistence.spi.PersistenceProvider]
INFO | main | o.a.a.j.container | - - | No quiesce support is available, so managed persistence units will not participate in quiesce operations.
INFO | main | e.u.n.c.s.d.ProvisionActivator | - - | System bundles installed.
INFO | Thread-4 | o.a.f.fileinstall | - - | Installing bundle db-connection / 1.0.0.SNAPSHOT
DEBUG | a\ucg\components | o.a.a.j.container | - - | Located Persistence descriptors: [META-INF/persistence.xml] db-connection_1.0.0.
DEBUG | a\ucg\components | o.a.a.j.container | - - | Located Persistence units: [Persistence unit testPU in bundle db-connection_1.0.0.
INFO | Thread-4 | e.u.n.c.e.db-connection | - - | BundleEvent INSTALLED
org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations 4.0.4.Final
org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core 4.2.7.Final
org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
org.hibernate.ejb.Ejb3Configuration configure
INFO: HHH000204: Processing PersistenceUnitInfo [
name: testPU
...]
org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator instantiateExplicitConnectionProvider
INFO: HHH000130: Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
INFO | main | .w.s.h.BeanNameUrlHandlerMapping | - - | Mapped URL path [/errors/*] onto handler '/errors/*'
INFO | main | o.s.b.f.c.PropertiesFactoryBean | - - | Loading properties file from class path resource [request-dispatcher.properties]
WARN | a\ucg\components | o.a.a.j.container | - - | Error creating EntityManagerFactory
java.lang.IllegalStateException: The bundle db-connection/1.0.0.SNAPSHOT is not started.
at org.apache.aries.jpa.container.unit.impl.JndiDataSource.getDs(JndiDataSource.java:62) ~[org.apache.aries.jpa.container-1.0.1-SNAPSHOT.jar:1.0.1-SNAPSHOT]
at org.apache.aries.jpa.container.unit.impl.DelayedLookupDataSource.getConnection(DelayedLookupDataSource.java:36) ~[org.apache.aries.jpa.container-1.0.1-SNAPSHOT.jar:1.0.1-SNAPSHOT]
at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:70) ~[na:na]
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcServicesImpl.java:242) ~[na:na]
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:117) ~[na:na]
at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:76) ~[na:na]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:160) ~[na:na]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:132) ~[na:na]
at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1822) ~[na:na]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1780) ~[na:na]
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:96) ~[na:na]
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914) ~[na:na]
at org.hibernate.osgi.OsgiPersistenceProvider.createContainerEntityManagerFactory(OsgiPersistenceProvider.java:99) ~[na:na]
at org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.createEntityManagerFactories(EntityManagerFactoryManager.java:331) [org.apache.aries.jpa.container-1.0.1-SNAPSHOT.jar:1.0.1-SNAPSHOT]
at org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.bundleStateChange(EntityManagerFactoryManager.java:175) [org.apache.aries.jpa.container-1.0.1-SNAPSHOT.jar:1.0.1-SNAPSHOT]
at org.apache.aries.jpa.container.impl.PersistenceBundleManager.modifiedBundle(PersistenceBundleManager.java:300) [org.apache.aries.jpa.container-1.0.1-SNAPSHOT.jar:1.0.1-SNAPSHOT]
at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:479) [org.apache.felix.framework-4.4.0.jar:na]
at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:414) [org.apache.felix.framework-4.4.0.jar:na]
at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232) [org.apache.felix.framework-4.4.0.jar:na]
at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:443) [org.apache.felix.framework-4.4.0.jar:na]
at org.apache.felix.framework.util.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:869) [org.apache.felix.framework-4.4.0.jar:na]
at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:790) [org.apache.felix.framework-4.4.0.jar:na]
at org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:515) [org.apache.felix.framework-4.4.0.jar:na]
at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4409) [org.apache.felix.framework-4.4.0.jar:na]
at org.apache.felix.framework.StatefulResolver.fireResolvedEvents(StatefulResolver.java:1126) [org.apache.felix.framework-4.4.0.jar:na]
at org.apache.felix.framework.StatefulResolver.resolve(StatefulResolver.java:439) [org.apache.felix.framework-4.4.0.jar:na]
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3973) [org.apache.felix.framework-4.4.0.jar:na]
at org.apache.felix.framework.Felix.startBundle(Felix.java:2043) [org.apache.felix.framework-4.4.0.jar:na]
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:976) [org.apache.felix.framework-4.4.0.jar:na]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1245) [org.apache.felix.fileinstall-3.4.0.jar:3.4.0]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1217) [org.apache.felix.fileinstall-3.4.0.jar:3.4.0]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:509) [org.apache.felix.fileinstall-3.4.0.jar:3.4.0]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:358) [org.apache.felix.fileinstall-3.4.0.jar:3.4.0]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:310) [org.apache.felix.fileinstall-3.4.0.jar:3.4.0]
INFO | Thread-4 | e.u.n.c.e.db-connection | - - | BundleEvent RESOLVED
org.hibernate.ejb.Ejb3Configuration configure
INFO: HHH000204: Processing PersistenceUnitInfo [
name: testPU
...]
org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator instantiateExplicitConnectionProvider
INFO: HHH000130: Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
ERROR | a\ucg\components | o.a.a.j.container | - - | The DataSource osgi:service/javax.sql.XADataSource/(osgi.jndi.service.name=jdbc/test) required by bundle db-connection/1.0.0.SNAPSHOT could not be found.
javax.naming.NoInitialContextException: Unable to find the InitialContextFactory org.apache.naming.java.javaURLContextFactory.
at org.apache.aries.jndi.ContextHelper.getInitialContext(ContextHelper.java:150) ~[na:na]
at org.apache.aries.jndi.OSGiInitialContextFactoryBuilder.getInitialContext(OSGiInitialContextFactoryBuilder.java:49) ~[na:na]
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684) ~[na:1.7.0_60]
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307) ~[na:1.7.0_60]
at javax.naming.InitialContext.init(InitialContext.java:242) ~[na:1.7.0_60]
at javax.naming.InitialContext.<init>(InitialContext.java:216) ~[na:1.7.0_60]
at org.apache.aries.jpa.container.unit.impl.JndiDataSource.getDs(JndiDataSource.java:64) ~[org.apache.aries.jpa.container-1.0.1-SNAPSHOT.jar:1.0.1-SNAPSHOT]
at org.apache.aries.jpa.container.unit.impl.DelayedLookupDataSource.getConnection(DelayedLookupDataSource.java:36) [org.apache.aries.jpa.container-1.0.1-SNAPSHOT.jar:1.0.1-SNAPSHOT]
at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:70) [hibernate-entitymanager-4.2.7.Final.jar:4.2.7.Final]
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcServicesImpl.java:242) [hibernate-core-4.2.7.Final.jar:4.2.7.Final]
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:117) [hibernate-core-4.2.7.Final.jar:4.2.7.Final]
at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:76) [hibernate-core-4.2.7.Final.jar:4.2.7.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:160) [hibernate-core-4.2.7.Final.jar:4.2.7.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:132) [hibernate-core-4.2.7.Final.jar:4.2.7.Final]
at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1822) [hibernate-core-4.2.7.Final.jar:4.2.7.Final]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1780) [hibernate-core-4.2.7.Final.jar:4.2.7.Final]
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:96) [hibernate-entitymanager-4.2.7.Final.jar:4.2.7.Final]
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914) [hibernate-entitymanager-4.2.7.Final.jar:4.2.7.Final]
at org.hibernate.osgi.OsgiPersistenceProvider.createContainerEntityManagerFactory(OsgiPersistenceProvider.java:99) [hibernate-osgi-4.2.7.Final.jar:4.2.7.Final]
at org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.createEntityManagerFactories(EntityManagerFactoryManager.java:331) [org.apache.aries.jpa.container-1.0.1-SNAPSHOT.jar:1.0.1-SNAPSHOT]
at org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.registerEntityManagerFactories(EntityManagerFactoryManager.java:242) [org.apache.aries.jpa.container-1.0.1-SNAPSHOT.jar:1.0.1-SNAPSHOT]
at org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.bundleStateChange(EntityManagerFactoryManager.java:185) [org.apache.aries.jpa.container-1.0.1-SNAPSHOT.jar:1.0.1-SNAPSHOT]
at org.apache.aries.jpa.container.impl.PersistenceBundleManager.modifiedBundle(PersistenceBundleManager.java:300) [org.apache.aries.jpa.container-1.0.1-SNAPSHOT.jar:1.0.1-SNAPSHOT]
at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:479) [org.apache.felix.framework-4.4.0.jar:na]
at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:414) [org.apache.felix.framework-4.4.0.jar:na]
at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232) [org.apache.felix.framework-4.4.0.jar:na]
at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:443) [org.apache.felix.framework-4.4.0.jar:na]
at org.apache.felix.framework.util.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:869) [org.apache.felix.framework-4.4.0.jar:na]
at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:790) [org.apache.felix.framework-4.4.0.jar:na]
at org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:515) [org.apache.felix.framework-4.4.0.jar:na]
at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4409) [org.apache.felix.framework-4.4.0.jar:na]
at org.apache.felix.framework.Felix.activateBundle(Felix.java:2142) [org.apache.felix.framework-4.4.0.jar:na]
at org.apache.felix.framework.Felix.startBundle(Felix.java:2070) [org.apache.felix.framework-4.4.0.jar:na]
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:976) [org.apache.felix.framework-4.4.0.jar:na]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1245) [org.apache.felix.fileinstall-3.4.0.jar:3.4.0]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1217) [org.apache.felix.fileinstall-3.4.0.jar:3.4.0]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:509) [org.apache.felix.fileinstall-3.4.0.jar:3.4.0]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:358) [org.apache.felix.fileinstall-3.4.0.jar:3.4.0]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:310) [org.apache.felix.fileinstall-3.4.0.jar:3.4.0]
我安装了以下 Bundle 来让 Hibernate 工作:
<dependency><groupId>org.apache.geronimo.specs</groupId><artifactId>geronimo-jta_1.1_spec</artifactId><version>1.1.1</version></dependency>
<dependency><groupId>org.apache.geronimo.specs</groupId><artifactId>geronimo-jpa_2.0_spec</artifactId><version>1.1</version></dependency>
<dependency><groupId>org.apache.aries.jpa</groupId><artifactId>org.apache.aries.jpa.api</artifactId><version>1.0.0</version></dependency>
<dependency><groupId>org.apache.aries.jpa</groupId><artifactId>org.apache.aries.jpa.blueprint.aries</artifactId><version>1.0.1</version></dependency>
<dependency><groupId>org.apache.aries.jpa</groupId><artifactId>org.apache.aries.jpa.container</artifactId><version>1.0.1</version></dependency>
<dependency><groupId>org.apache.aries.jpa</groupId><artifactId>org.apache.aries.jpa.container.context</artifactId><version>1.0.1</version></dependency>
<!--hibernate 4.2.7 -->
<dependency><groupId>org.apache.servicemix.bundles</groupId><artifactId>org.apache.servicemix.bundles.antlr</artifactId><version>2.7.7_5</version></dependency>
<dependency><groupId>org.apache.servicemix.bundles</groupId><artifactId>org.apache.servicemix.bundles.ant</artifactId><version>1.8.2_2</version></dependency>
<dependency><groupId>org.apache.servicemix.bundles</groupId><artifactId>org.apache.servicemix.bundles.dom4j</artifactId><version>1.6.1_5</version></dependency>
<dependency><groupId>org.apache.servicemix.bundles</groupId><artifactId>org.apache.servicemix.bundles.serp</artifactId><version>1.14.1_1</version></dependency>
<dependency><groupId>com.fasterxml</groupId><artifactId>classmate</artifactId><version>0.9.0</version></dependency>
<dependency><groupId>org.javassist</groupId><artifactId>javassist</artifactId><version>3.18.1-GA</version></dependency>
<dependency><groupId>org.jboss.spec.javax.security.jacc</groupId><artifactId>jboss-jacc-api_1.4_spec</artifactId><version>1.0.2.Final</version></dependency>
<dependency><groupId>org.jboss</groupId><artifactId>jandex</artifactId><version>1.1.0.Final</version></dependency>
<dependency><groupId>org.jboss.logging</groupId><artifactId>jboss-logging</artifactId><version>3.1.4.GA</version></dependency>
<dependency><groupId>org.hibernate.common</groupId><artifactId>hibernate-commons-annotations</artifactId><version>4.0.4.Final</version></dependency>
<dependency><groupId>org.hibernate</groupId><artifactId>hibernate-core</artifactId><version>4.2.7.Final</version></dependency>
<dependency><groupId>org.hibernate</groupId><artifactId>hibernate-entitymanager</artifactId><version>4.2.7.Final</version></dependency>
<dependency><groupId>org.hibernate</groupId><artifactId>hibernate-osgi</artifactId><version>4.2.7.Final</version></dependency>
<!-- JTA -->
<dependency><groupId>org.apache.aries.transaction</groupId><artifactId>org.apache.aries.transaction.blueprint</artifactId><version>1.0.1</version></dependency>
<dependency><groupId>org.apache.aries.transaction</groupId><artifactId>org.apache.aries.transaction.manager</artifactId><version>1.1.0</version></dependency>
<!-- JNDI -->
<dependency><groupId>org.apache.xbean</groupId><artifactId>xbean-naming</artifactId><version>3.16</version></dependency>
<dependency><groupId>org.apache.aries.jndi</groupId><artifactId>org.apache.aries.jndi.api</artifactId><version>1.0.0</version></dependency>
<dependency><groupId>org.apache.aries.jndi</groupId><artifactId>org.apache.aries.jndi.core</artifactId><version>1.0.0</version></dependency>
<dependency><groupId>org.apache.aries.jndi</groupId><artifactId>org.apache.aries.jndi.rmi</artifactId><version>1.0.0</version></dependency>
<dependency><groupId>org.apache.aries.jndi</groupId><artifactId>org.apache.aries.jndi.url</artifactId><version>1.0.0</version></dependency>
<dependency><groupId>org.apache.aries.jndi</groupId><artifactId>org.apache.aries.jndi.legacy.support</artifactId><version>1.0.0</version></dependency>
<dependency><groupId>org.apache.aries.proxy</groupId><artifactId>org.apache.aries.proxy</artifactId><version>1.0.1</version></dependency>
【问题讨论】:
【参考方案1】:这是 aries jpa 1.0.0 中的一个错误。见Issue aries-1160。 它在version 1.0.1 which is currently being voted on 中修复。所以你应该在几天后在 maven Central 中找到这个版本。
与此同时,您可以从staging repository 测试修复。只需在部署中交换 aries jpa jar 版本。顺便提一句。新版本还应该允许使用 hibernate 4.3 版本,因为它也兼容 jpa 2.1。
【讨论】:
是的,我知道这个问题。我包括 aries.jpa.container 1.0.1.-SNAPSHOT。 javax.naming.NoInitialContextException 的任何线索:无法找到 InitialContextFactory org.apache.naming.java.javaURLContextFactory。 ? 你可能缺少 aries jndi 吗? 我编辑了答案,包括与休眠集成相关的 aries 依赖项以上是关于Apache Felix 中的 JPA / Hibernate 集成的主要内容,如果未能解决你的问题,请参考以下文章
在 Apache Felix (v 4.2.1) Gogo shell 上,未打印捆绑包中的 System.out.println
m2eclipse Error:ArtifactTransferException: Failure to transfer org.apache.felix:org.apache.felix.res
org.apache.felix.framework-5.6.12源码解析——org.apache.felix.framework文件夹最后的部分