title: Camel JPA XML Configuration with EntityManagers
body: <p>I'm trying to use JPA to save an Entity to a database using Camel.</p>
  
  <p>I have my persistence.xml as this:</p>
  
  <pre><code>&lt;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"&gt;
  
     &lt;persistence-unit name="my-pu"&gt;
       &lt;description&gt;My Persistence Unit&lt;/description&gt;
       &lt;class&gt;org.bencompany.camel.JabberMessage&lt;/class&gt;
       &lt;provider&gt;org.apache.openjpa.persistence.PersistenceProviderImpl&lt;/provider&gt;
       &lt;properties&gt;
         &lt;property name="openjpa.ConnectionURL"   value="mysql://localhost/jabber"/&gt;
         &lt;property name="openjpa.ConnectionDriverName" value="org.mysql.jdbc.Driver"/&gt;
         &lt;property name="javax.persistence.jdbc.user" value="root"/&gt;
         &lt;property name="javax.persistence.jdbc.password" value="root"/&gt;
         &lt;property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema"/&gt;
          &lt;property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO"/&gt;
       &lt;/properties&gt;
     &lt;/persistence-unit&gt;
  
  &lt;/persistence&gt;
  </code></pre>
  
  <p>and my camel / beans .xml is this:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;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"&gt;
  
      &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean"&gt;
          &lt;property name="persistenceUnitName" value="my-pu" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="jpa" class="org.apache.camel.component.jpa.JpaComponent"&gt;
          &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="myProcessor" class="org.bencompany.camel.JabberProcessor" /&gt;
  
      &lt;camelContext xmlns="http://camel.apache.org/schema/blueprint"
          xmlns:order="http://fusesource.com/examples/order/v7" id="cbr-example-context"&gt;
  
          &lt;route id="sendMessage"&gt;
              &lt;from uri="file:work/cbr/input" /&gt;
              &lt;log message="Sending Message: ${body}" /&gt;
              &lt;to uri="xmpp://benco@xxx.com/?room=benco@conference.xxx.com&amp;amp;password=xx&amp;amp;nickname=bencamelbot" /&gt;
          &lt;/route&gt;
  
          &lt;route id="recieveMessage"&gt;
              &lt;from uri="xmpp://benco@xxx.com/?room=benco@conference.xxx.com&amp;amp;password=xx&amp;amp;nickname=bencamelbot" /&gt;
              &lt;to uri="myProcessor" /&gt;
              &lt;to uri="jpa://" /&gt;
          &lt;/route&gt;
  
      &lt;/camelContext&gt;
  &lt;/blueprint&gt;
  </code></pre>
  
  <p>I'm using Blueprint as I'm trying to deploy this onto JBoss Fuse. I've been using the following link as a reference, and I have followed it to the tee: <a href="https://access.redhat.com/documentation/en-US/Red_Hat_JBoss_Fuse/6.0/html/EIP_Component_Reference/files/_IDU_JPA.html" rel="nofollow">https://access.redhat.com/documentation/en-US/Red_Hat_JBoss_Fuse/6.0/html/EIP_Component_Reference/files/_IDU_JPA.html</a></p>
  
  <p>But when I try to deploy my application, I get this error.</p>
  
  <pre><code>org.osgi.service.blueprint.container.ComponentDefinitionException: Error setting property: PropertyDescriptor &lt;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
  </code></pre>
  
  <p>The LocalEntityManagerFactoryBean is supposed to create an EntityManagerFactory, and I'm doing exactly what the JBoss / Camel documentation says, but this error is coming up.</p>
  
  <p>Any ideas?</p>