Hi Can you post the real stacktrace? Usually the have line numbers and whatnot. Also mention the Camel and Karaf version you use.
On Thu, Jun 21, 2012 at 9:35 AM, Sriraman Gopalan <sreeraa...@gmail.com> wrote: > Dear All, > > I have a camel route that polls the database (using a jpa consumer) as shown > below: > > Camel Route: > > ================================================================= > from("jpa:samples.CustomerAccount?consumer.namedQuery=selectAllCustomerAccounts&consumeDelete=false") > .to("log:test-out") > > My persistence.xml is as follows: > ================================================================= > <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="pdsprint1" transaction-type="JTA"> > > <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider> > > <jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/pdsprint1)</jta-data-source> > > <class>samples.CustomerAccount</class> > <class>samples.AccountInfo</class> > > <exclude-unlisted-classes>true</exclude-unlisted-classes> > > <properties> > <property name="openjpa.ConnectionFactoryMode" value="managed"/> > <property name="openjpa.jdbc.SynchronizeMappings" > value="buildSchema"/> > <property name="openjpa.jdbc.DBDictionary" > value="org.apache.openjpa.jdbc.sql.H2Dictionary"/> > <property name="openjpa.ManagedRuntime" > value="jndi(TransactionManagerName=osgi:service/javax.transaction.TransactionManager)"/> > <property name="openjpa.Log" value="DefaultLevel=TRACE, > Tool=INFO" /> > </properties> > </persistence-unit> > > </persistence> > > ================================================================ > > My blueprint configuration is as follows: > > <bean id="jpa" class="org.apache.camel.component.jpa.JpaComponent"> > <tx:transaction method="*" /> > <property name="entityManagerFactory" > ref="entityManagerFactory" /> > <property name="transactionManager" ref="transactionManager" /> > </bean> > > <bean id="transactionManager" > class="org.springframework.orm.jpa.JpaTransactionManager"> > <property name="entityManagerFactory" > ref="entityManagerFactory" /> > </bean> > > <reference id="entityManagerFactory" > interface="javax.persistence.EntityManagerFactory" > filter="(osgi.unit.name=pdsprint1)" /> > > ================================================================= > > However, I am getting the following error when I start the bundle: > > Consumer[jpa://samples.CustomerAccount?consumeDelete=false?consumer.delay=10000&consumer.namedQuery=selectAllCustomerAccounts] > could not poll endpoint: > Endpoint[jpa://samples.CustomerAccount?consumeDelete=false?consumer.delay=10000&consumer.namedQuery=selectAllCustomerAccounts] > caused by: Could not open JPA EntityManager for transaction; nested > exception is <openjpa-2.1.1-r422266:1148538 nonfatal user error> > org.apache.openjpa.persistence.InvalidStateException: You cannot access the > EntityTransaction when using managed transactions. > org.springframework.transaction.CannotCreateTransactionException: Could not > open JPA EntityManager for transaction; nested exception is > <openjpa-2.1.1-r422266:1148538 nonfatal user error> > org.apache.openjpa.persistence.InvalidStateException: You cannot access the > EntityTransaction when using managed transactions. > > Note: > > I have the following features installed in Karaf: > > 1. jpa > 2. jndi > 3. transaction > 4. camel-jpa > > Also, my data source is configured via another bundle as shown below as > suggested by > Christian Schneider in his blog > > http://www.liquid-reality.de/display/liquid/2012/01 > > ================================================================= > > <cm:property-placeholder persistent-id="samples.datasource"> > </cm:property-placeholder> > > <bean id="dataSource" class="org.h2.jdbcx.JdbcDataSource"> > <property name="URL" value="${db.url}" /> > <property name="user" value="${db.userid}" /> > <property name="password" value="${db.password}" /> > </bean> > > <service interface="javax.sql.DataSource" ref="dataSource"> > <service-properties> > <entry key="osgi.jndi.service.name" > value="jdbc/pdsprint1" /> > </service-properties> > </service> > > ================================================================= > Can somebody point me in the right direction? > > best regards > Sriraman. > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Problem-with-Camel-Jpa-Component-and-Container-Managed-Transaction-tp5714815.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Claus Ibsen ----------------- FuseSource Email: cib...@fusesource.com Web: http://fusesource.com Twitter: davsclaus, fusenews Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen