Hi,

In my project, I am using JPA and using Hibernate vendor to poll tables.
Please see my config below.  I am trying to setup multiple persiste
http://old.nabble.com/file/p28237771/trace-jpa.txt trace-jpa.txt nce.xml
file in my project.

<bean>
<camel-context>
...
        <route>
                        <from
uri="jpa:com.MyEntity?consumer.namedQuery=pollRecords&amp;consumeDelete=false&amp;delay=1000&amp;consumer.useFixedDelay=true"/>
                        <to uri="bean:rransformerBean?method=transformRecords"/>
                </route>
<camel-context/>
 <bean id="jpaTemplate" class="org.springframework.orm.jpa.JpaTemplate">
    <property name="entityManagerFactory" ref="entityManagerFactory"/>
  </bean>
<bean id="myPersistence"
class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
  <property name="persistenceXmlLocations">
    <list>
      <value>classpath*:META-INF/spring/custom/persistence.xml</value>
    </list>
  </property>
 <property name="loadTimeWeaver">
        <bean
class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/>
 </property>
</bean>
 <bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="persistenceUnitName" value="camel"/>
        <property name="persistenceUnitManager" ref="myPersistence" />
        <property name="jpaVendorAdapter">
                <bean
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                 <property name="showSql" value="false"/>
                </bean>
        </property>

</bean>
I am using Spring config to setup the multiple peristence xml location, you
can see the example
http://docs.huihoo.com/spring/2.5.x/en-us/orm.html#orm-jpa-setup-lcemfb .  
When running the camel application I have come to know that  Spring has
successfully created entity
http://old.nabble.com/file/p28237771/trace-jpa.txt trace-jpa.txt
ManagerFactory and loaded correct persistence.xml file. However, when camel
starts, JPA endpoint tries to create/instantiate new entityManagerFactory
Object again instead of using existing entityManageFactory that was already
created by spring. In doing so, EJB3Configuration.configure()  is invoked by
Jpa endpoint throws an error stating "Could not find any
META-INF/persistence.xml file in the classpath". Why is camel JPA endpoint
invoking  Persistence.createEntityManagerFactory(persistenceUnit,
getEntityManagerProperties()); instead of reusing entityMangerFactory that
was instantiated by Spring? Is camel getting confused between
LocalEntityManagerFactory  and LocalContainerEntityManagerFactory ? I have
added trace logs of camel, spring and hibernate in the attachment to this
post. Hopefully it helps you explain my questions.

Kind regards,
-Vid-





-- 
View this message in context: 
http://old.nabble.com/JPA-component---EntityManagerFactory-issue-tp28237771p28237771.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to