我正在尝试使用 JPA 将实体保存到使用 Camel 的数据库中。
我有我的 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_1_0.xsd" version="1.0">
<persistence-unit name="my-pu">
<description>My Persistence Unit</description>
<class>org.bencompany.camel.JabberMessage</class>
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<properties>
<property name="openjpa.ConnectionURL" value="mysql://localhost/jabber"/>
<property name="openjpa.ConnectionDriverName" value="org.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.user" value="root"/>
<property name="javax.persistence.jdbc.password" value="root"/>
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema"/>
<property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO"/>
</properties>
</persistence-unit>
</persistence>
我的骆驼/豆类 .xml 是这样的:
<?xml version="1.0"?>
<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
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
<property name="persistenceUnitName" value="my-pu" />
</bean>
<bean id="jpa" class="org.apache.camel.component.jpa.JpaComponent">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<bean id="myProcessor" class="org.bencompany.camel.JabberProcessor" />
<camelContext xmlns="http://camel.apache.org/schema/blueprint"
xmlns:order="http://fusesource.com/examples/order/v7" id="cbr-example-context">
<route id="sendMessage">
<from uri="file:work/cbr/input" />
<log message="Sending Message: ${body}" />
<to uri="xmpp://benco@xxx.com/?room=benco@conference.xxx.com&password=xx&nickname=bencamelbot" />
</route>
<route id="recieveMessage">
<from uri="xmpp://benco@xxx.com/?room=benco@conference.xxx.com&password=xx&nickname=bencamelbot" />
<to uri="myProcessor" />
<to uri="jpa://" />
</route>
</camelContext>
</blueprint>
我正在使用蓝图,因为我试图将它部署到 JBoss Fuse 上。我一直在使用以下链接作为参考,并且一直关注它:https ://access.redhat.com/documentation/en-US/Red_Hat_JBoss_Fuse/6.0/html/EIP_Component_Reference/files/_IDU_JPA.html
但是当我尝试部署我的应用程序时,我收到了这个错误。
org.osgi.service.blueprint.container.ComponentDefinitionException: Error setting property: PropertyDescriptor <name: entityManagerFactory, getter: class org.apache.camel.component.jpa.JpaComponent.getEntityManagerFactory(), setter: [class org.apache.camel.component.jpa.JpaComponent.setEntityManagerF
actory(interface javax.persistence.EntityManagerFactory)]
Caused by: java.lang.Exception: Unable to convert value org.springframework.orm.jpa.LocalEntityManagerFactoryBean@3ce0f4c8 to type javax.persistence.EntityManagerFactory
LocalEntityManagerFactoryBean 应该创建一个 EntityManagerFactory,我正在按照 JBoss / Camel 文档所说的那样做,但是这个错误即将出现。
有任何想法吗?