AnsweredAssumed Answered

JTA bug

Question asked by dumitru.ciubenco on Oct 1, 2012
Latest reply on Oct 3, 2012 by jbarrez
I'm using Activiti(5.10) on JBoss 7 with EJB3.1+JPA2+JTA,

After completing one task which has jpa-entity variable, application crashes when activiti tryies to retrieve jpa entity from the DB with the folowing stack:

java.lang.IllegalStateException: A JTA EntityManager cannot use getTransaction()
   org.hibernate.ejb.AbstractEntityManagerImpl.getTransaction(AbstractEntityManagerImpl.java:996)
   sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   java.lang.reflect.Method.invoke(Method.java:601)
   org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:365)
   $Proxy569.getTransaction(Unknown Source)
   org.activiti.engine.impl.variable.EntityManagerSessionImpl.isTransactionActive(EntityManagerSessionImpl.java:66)
   org.activiti.engine.impl.variable.EntityManagerSessionImpl.getEntityManager(EntityManagerSessionImpl.java:109)
   org.activiti.engine.impl.variable.JPAEntityMappings.findEntity(JPAEntityMappings.java:123)
   org.activiti.engine.impl.variable.JPAEntityMappings.getJPAEntity(JPAEntityMappings.java:119)
   org.activiti.engine.impl.variable.JPAEntityVariableType.getValue(JPAEntityVariableType.java:77)
   org.activiti.engine.impl.persistence.entity.VariableInstanceEntity.getValue(VariableInstanceEntity.java:158)
   org.activiti.engine.impl.persistence.entity.VariableScopeImpl.getVariable(VariableScopeImpl.java:93)
   org.activiti.engine.impl.cmd.GetExecutionVariableCmd.execute(GetExecutionVariableCmd.java:60)
   org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
   org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:42)
   org.activiti.engine.impl.interceptor.JtaTransactionInterceptor.execute(JtaTransactionInterceptor.java:59)
   org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
   org.activiti.engine.impl.RuntimeServiceImpl.getVariable(RuntimeServiceImpl.java:103)


I can see there is method in the EntityManagerSessionImpl:

  protected boolean isTransactionActive() {
    if (handleTransactions && entityManager.getTransaction() != null) {
      return entityManager.getTransaction().isActive();
    }
    return false;
  }

I think entityManager.getTransaction() is not applicable for JTA case, or I'm wrong?

regards,
Dima

Outcomes