无法在OSGI上创建EntityManager

时间:2015-01-19 16:15:32

标签: java hibernate blueprint-osgi fabric8

我正在使用fabric8版本1.1.0CR5 当我尝试使用hibernate作为DAL部署服务时,我收到了这个错误:

2015-01-19 16:15:33,402 | ERROR | rint Extender: 2 | BlueprintContainerImpl           | 111 - org.apache.aries.blueprint.core - 1.4.0 | Unable to start blueprint container for bundle it.gestielle.OpenFund_CXF due to unresolved dependencies [(&(&(org.apache.aries.jpa.proxy.factory=true)(osgi.unit.name=managed-jpa))(objectClass=javax.persistence.EntityManagerFactory))]
java.util.concurrent.TimeoutException
	at org.apache.aries.blueprint.container.BlueprintContainerImpl$1.run(BlueprintContainerImpl.java:336)[111:org.apache.aries.blueprint.core:1.4.0]
	at org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)[111:org.apache.aries.blueprint.core:1.4.0]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[:1.7.0_67]
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)[:1.7.0_67]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)[:1.7.0_67]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)[:1.7.0_67]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[:1.7.0_67]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.7.0_67]
	at java.lang.Thread.run(Thread.java:745)[:1.7.0_67]

这是我的features.xml:

<?xml version="1.0" encoding="UTF-8"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.0.0">
	<repository>mvn:it.gestielle/OpenFund_CXF/${project.version}/xml/features</repository>
	<feature name="OpenFund_CXF" version='${project.version}' resolver="(obr)">
        <feature>jpa</feature>
        <feature>jndi</feature>
        <feature>swagger</feature>
		<feature version="${cxf.version}">cxf-jaxrs</feature>
		<feature version="${cxf.version}">cxf-rs-security-cors</feature>
		
		<config name="org.apache.aries.transaction">
            aries.transaction.recoverable = true
            aries.transaction.timeout = 600
            aries.transaction.howl.maxLogFiles = 2
            aries.transaction.howl.maxBlocksPerFile = 512
            aries.transaction.howl.bufferSizeKBytes = 4
        </config>
        
        <!-- JDBC Driver -->
        <bundle>wrap:mvn:org.postgresql/postgresql/9.3-1102-jdbc41</bundle>
		<bundle>mvn:com.microsoft.sqlserver/sqljdbc4/4.0.2206.100</bundle>
       
	    <!-- Hibernate -->
        <bundle>mvn:com.fasterxml/classmate/0.9.0</bundle>
        <bundle>mvn:org.apache.geronimo.specs/geronimo-servlet_3.0_spec/1.0</bundle>
        <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.antlr/2.7.7_5</bundle>
        <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.ant/1.8.2_2</bundle>
        <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.dom4j/1.6.1_5</bundle>
        <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.serp/1.14.1_1</bundle>
        <bundle>mvn:org.javassist/javassist/3.18.1-GA</bundle>
        <bundle>mvn:org.jboss.spec.javax.security.jacc/jboss-jacc-api_1.4_spec/1.0.2.Final</bundle>
        <bundle>wrap:mvn:org.jboss/jandex/1.1.0.Final</bundle>
        <bundle>mvn:org.jboss.logging/jboss-logging/3.1.3.GA</bundle>
        <bundle>mvn:org.hibernate.common/hibernate-commons-annotations/4.0.5.Final</bundle>
        <bundle>mvn:org.hibernate.javax.persistence/hibernate-jpa-2.1-api/1.0.0.Final</bundle>
        <bundle>mvn:org.hibernate/hibernate-core/4.3.6.Final</bundle>
        <bundle>mvn:org.hibernate/hibernate-entitymanager/4.3.6.Final</bundle>
        <bundle>mvn:org.hibernate/hibernate-osgi/4.3.6.Final</bundle>
        
        <bundle>mvn:it.gestielle/OpenFund_DataSource/${project.version}</bundle>
        <bundle>mvn:it.gestielle/OpenFund_CXF/${project.version}</bundle>
	</feature>
</features>

这是我创建使用DAL的bean的蓝图:

<?xml version="1.0" encoding="UTF-8"?>
<blueprint default-activation="eager" 
	xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
	xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
	xmlns:cxf="http://cxf.apache.org/blueprint/core"
	xmlns:jaxrs="http://cxf.apache.org/blueprint/jaxrs"
	xmlns:jpa="http://aries.apache.org/xmlns/jpa/v1.1.0"
	xmlns:tx="http://aries.apache.org/xmlns/transactions/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
		http://camel.apache.org/schema/blueprint
		http://camel.apache.org/schema/blueprint/camel-blueprint-2.8.0.xsd
		http://aries.apache.org/xmlns/jpa/v1.1.0
		http://aries.apache.org/schemas/jpa/jpa_110.xsd
		http://aries.apache.org/xmlns/transactions/v1.0.0
		http://aries.apache.org/schemas/transaction/transactionv10.xsd
		http://cxf.apache.org/blueprint/jaxrs 
		http://cxf.apache.org/schemas/blueprint/jaxrs.xsd
		http://cxf.apache.org/blueprint/core 
		http://cxf.apache.org/schemas/blueprint/core.xsd">

	<jaxrs:server id="OpenFundService" address="/openfundservice">
		<jaxrs:serviceBeans>
			<ref component-id="OpenFundSvc"/>
		</jaxrs:serviceBeans>
		<jaxrs:features>
			<bean class="io.fabric8.cxf.endpoint.SwaggerFeature"/>
            <bean class="io.fabric8.cxf.endpoint.ManagedApiFeature"/>
		</jaxrs:features>
		<jaxrs:providers>
			<bean class="com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider"/>
			<ref component-id="corsFilter"/>
		</jaxrs:providers>
	</jaxrs:server>

	<cxf:bus>
		<cxf:features>
			<cxf:logging />
		</cxf:features>
	</cxf:bus>

	<bean id="corsFilter" class="org.apache.cxf.rs.security.cors.CrossOriginResourceSharingFilter"/>

	<bean id="OpenFundSvc" class="it.gestielle.openfund.cxf.OpenFundService">
		<jpa:context unitname="managed-jpa" property="openFundEM"/>
	</bean>
	
</blueprint>

这是persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" 
	xmlns="http://xmlns.jcp.org/xml/ns/persistence" 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">

	<persistence-unit name="managed-jpa">
		<provider>org.hibernate.ejb.HibernatePersistence</provider>
		<jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/OpenFund_PGSQL_DS)</jta-data-source>
		<class>it.gestielle.openfund.model.Documenti</class>
		<class>it.gestielle.openfund.model.TipiDocumenti</class>

		<properties>
			<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
			<property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/>
		</properties>
	</persistence-unit>
</persistence>

有人能帮帮我吗? 谢谢 米尔科

0 个答案:

没有答案