AnsweredAssumed Answered

flush without tx.begin() - problem with JPA variable

Question asked by p4w3l on Apr 6, 2012
I try simple JPA configuration with tested JPA classes and persistence.xml. I am not sure if it is importand but it works standalone with: EclipseLink 2.3.2, Tomcat 6. When added 3 lines to activiti-context.xml from user manual and simply: find an object from em, put into variables map and start a process I receive error exception with:

Exception Description: No transaction is currently active

It looks for me that EntityManagerSessionImpl never begins the transaction. Here below are fragments that may say more about my case:

<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
     <property name="jndiName" value="java:comp/env/jdbc/bpm"/>

<bean id="transactionManager"
<property name="dataSource" ref="dataSource" />

<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
    <property name="dataSource" ref="dataSource" />
    <property name="transactionManager" ref="transactionManager" />
    <property name="jpaPersistenceUnitName" value="default" />
    <property name="jpaHandleTransaction" value="true" />
    <property name="jpaCloseEntityManager" value="true" />

<persistence-unit name="default" transaction-type="RESOURCE_LOCAL">

Except JPA variables that I have just wanted to add to project - everything else works fine. I can manage to use Activiti and JPA independently. Just started to evaluate JPA variables I got stucked with that flush() that has no active transaction.

After analisys of two code of: org.activiti.engine.impl.variable.EntityManagerSessionImpl and org.activiti.engine.impl.variable.JPAEntityVariableType it looks for me that somehow the code finds the transaction active what cannot be true after my simple em.find(…) and trying flush without first tx.begin().

Is this maybe a bug to report? Would you please test a simple JPA variable without any special JTA like in my case and give me configuration example?