ServiceMix的/ JPA集成 - LocalContainerEntityManagerFactoryBean键入的EntityManagerFactory [英] ServiceMix / JPA Integration - LocalContainerEntityManagerFactoryBean to type EntityManagerFactory
问题描述
我是相当新的ServiceMix的/ JPA /骆驼/弹簧。我试图用骆驼JPA组件作为我的骆驼路线的一部分。我使用的ServiceMix的最新版本,这是4.5.1。它使用骆驼2.10.4和春季3.0.7。
I'm fairly new to ServiceMix / JPA / Camel / Spring. I'm attempting to use the camel-jpa component as part of my camel route. I'm using the latest release of ServiceMix, which is 4.5.1. This uses camel 2.10.4 and spring 3.0.7.
更新OSGi的清单和部署一些额外的模块来ServiceMix的之后,我被困在下面的堆栈跟踪:
After updating the OSGi manifest and deploying some additional modules to servicemix, I am stuck on the following stack trace:
org.osgi.service.blueprint.container.ComponentDefinitionException: Error setting property: PropertyDescriptor <name: entityManagerFactory, getter: class org.springframework.orm.jpa.JpaTransactionManager.getEntityManagerFactory(, setter: [class org.springframework.orm.jpa.JpaTransactionManager.setEntityManagerFactory(interface javax.persistence.EntityManagerFactory]
[...]
Caused by: java.lang.Exception: Unable to convert value org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean@46e9e26a to type javax.persistence.EntityManagerFactory
at org.apache.aries.blueprint.container.AggregateConverter.convert(AggregateConverter.java:172)[10:org.apache.aries.blueprint:0.3.2]
at org.apache.aries.blueprint.container.BlueprintRepository.convert(BlueprintRepository.java:373)[10:org.apache.aries.blueprint:0.3.2]
at org.apache.aries.blueprint.utils.ReflectionUtils$PropertyDescriptor.convert(ReflectionUtils.java:322)[10:org.apache.aries.blueprint:0.3.2]
at org.apache.aries.blueprint.utils.ReflectionUtils$MethodPropertyDescriptor.internalSet(ReflectionUtils.java:555)[10:org.apache.aries.blueprint:0.3.2]
at org.apache.aries.blueprint.utils.ReflectionUtils$PropertyDescriptor.set(ReflectionUtils.java:306)[10:org.apache.aries.blueprint:0.3.2]
at org.apache.aries.blueprint.container.BeanRecipe.setProperty(BeanRecipe.java:819)[10:org.apache.aries.blueprint:0.3.2]
我已经与我的persistence.xml,骆驼的context.xml(蓝图/ Spring XML中)扮演周围并没有能够取得多大进展。我现在的配置是:
I've played around with my persistence.xml, camel-context.xml (blueprint/spring xml) and have not been able to make much progress. My current configuration is:
骆驼context.xml中
camel-context.xml
<bean id="mysqlDataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost/prototype"/>
<property name="username" value="...."/>
<property name="password" value="...."/>
</bean>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="mysqlDataSource"/>
<property name="persistenceUnitName" value="customer1"/>
<property name="loadTimeWeaver">
<bean class="org.springframework.instrument.classloading.SimpleLoadTimeWeaver" />
</property>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter">
<property name="databasePlatform" value="org.apache.openjpa.jdbc.sql.MySQLDictionary" />
<property name="showSql" value="true"/>
</bean>
</property>
</bean>
<bean id="jpaTxManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<bean id="jpa" class="org.apache.camel.component.jpa.JpaComponent">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
<property name="transactionManager" ref="jpaTxManager"/>
</bean>
的persistence.xml
persistence.xml
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="customer1" transaction-type="RESOURCE_LOCAL">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<class>....</class>
</persistence-unit>
任何帮助将是AP preciated。我一直在纺纱在这个问题上几天了。
Any help would be appreciated. I've been spinning on this problem for a couple days now.
推荐答案
当你使用JPA白羊座和JTA功能已经使用Blueprint是你所需要的。
为此,您需要安装这些功能也(JPA / JTA),并确保您的交易类型JTA的,与使用白羊实体管理器,而不是春天,你应该在安全方面的。一个DAO会看起来更像以下内容:
As your already using Blueprint using the Aries JPA and JTA features is what you need. For this you need to install those features also (JPA/JTA) and make sure your transaction is of type JTA, with that and using the entity manager of Aries instead of spring you should be on the safe side. A DAO will look more like the following:
<bean id="daoBean" class="dummy.class.name.DaoBean">
<jpa:context property="em" unitname="customer1" />
<tx:transaction method="*" value="Required" />
</bean>
对于这个正常工作,你需要引用相应的蓝图架构。
For this to work properly you need to reference the corresponding blueprint schemas.
这篇关于ServiceMix的/ JPA集成 - LocalContainerEntityManagerFactoryBean键入的EntityManagerFactory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!