You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by martin11 <ma...@gmail.com> on 2013/04/05 09:57:44 UTC

JPA: Transaction marked as rollbackOnly

Hello, 

I'm using latest camel 2.10.4 and I'm trying to learn JPA component.
I want to use database table as a logical queue (remove detached row from
table)

There is my camel context:
<camel:route id="route-from-db">
    <camel:from
uri="jpa:com.test.dto.Property?consumer.namedQuery=myquery&amp;consumeDelete=true"/>
    <camel:process ref="testingProcessor"/>
</camel:route>

JPA bean configuration:

<bean id="jpa" class="org.apache.camel.component.jpa.JpaComponent">
    <property name="entityManagerFactory" ref="entityManagerFactory"/>
    <property name="transactionManager" ref="transactionManager"/>
</bean>

<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
    <property name="persistenceUnitName" value="mydb"/>
    <property name="jpaVendorAdapter">
        <bean
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
            <property name="databasePlatform"
value="org.hibernate.dialect.MySQLDialect"/>
            <property name="database" value="MYSQL"/>
        </bean>
    </property>
</bean>

<bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>

<bean id="transactionTemplate"
class="org.springframework.transaction.support.TransactionTemplate">
    <property name="transactionManager" ref="transactionManager"/>
</bean>

I got an error: Transaction marked as rollbackOnly

05.04.2013 09:38:44.995 [Camel (olomoucContext) thread #1 -
jpa://com.test.dto.Property] o.a.c.c.j.JpaConsumer(224) - WARN  - Consumer
Consumer[jpa://com.test.dto.Property?consumeDelete=true&consumer.namedQuery=myquery]
failed polling endpoint:
Endpoint[jpa://com.test.dto.Property?consumeDelete=true&consumer.namedQuery=myquery].
Will try again at next poll. Caused by:
[org.springframework.transaction.TransactionSystemException - Could not
commit JPA transaction; nested exception is
javax.persistence.RollbackException: Transaction marked as rollbackOnly]
org.springframework.transaction.TransactionSystemException: Could not commit
JPA transaction; nested exception is javax.persistence.RollbackException:
Transaction marked as rollbackOnly
	at
org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:476)
~[spring-orm-3.0.7.RELEASE.jar:3.0.7.RELEASE]
	at
org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
~[spring-tx-3.0.7.RELEASE.jar:3.0.7.RELEASE]
	at
org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
~[spring-tx-3.0.7.RELEASE.jar:3.0.7.RELEASE]


What I'm missing in configuration? How can I begin requested transaction
(readOnly = false) to remove item from database? 
If camel JPA option consumeDelete=false I get data from my database...

Thanks in Advice

--
Martin



--
View this message in context: http://camel.465427.n5.nabble.com/JPA-Transaction-marked-as-rollbackOnly-tp5730381.html
Sent from the Camel - Users mailing list archive at Nabble.com.