cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with CdiJtaProcessEngineConfiguration

yahekia
Champ in-the-making
Champ in-the-making
I have a problem with the transactions.

My application is an EJB where I inject the processEngine, the idea is to let the ejb manage the transactions. At the beginning I was using CdiProcessEngineConfiguration and now I have changed to CdiJtaProcessEngineConfiguration. The problem is that when I create the process is set some variables, and then in an ActivitiListener I try to read them and at this point it raise an exeption that says that the execution with id X do not exists. For me it seems that it is a problem with the configuration of the engine.

So here it is



public class ProgrammaticProcessEngineConfiguration implements ProcessEngineLookup {

    private ProcessEngine processEngine;
    private EntityManagerFactory emf;

    @Override
    public ProcessEngine getProcessEngine() {
       CdiJtaProcessEngineConfiguration processEngineConfiguration = new CdiJtaProcessEngineConfiguration();
       
        processEngineConfiguration.setTransactionsExternallyManaged(true)
                .setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE)
                .setJobExecutorActivate(true).setHistory("audit");
       
        try {
         processEngineConfiguration.setTransactionManager(getTransactionManager());
      } catch (Exception e) {
         throw new FSPException("no.transaction.manager", e);
      }
        processEngineConfiguration.setDataSourceJndiName("jboss/datasources/ActivitiDsMysql");

        emf = Persistence.createEntityManagerFactory("fsp-jpa-extendedTask");
        processEngineConfiguration.setJpaEntityManagerFactory(emf);
        processEngineConfiguration.setJpaHandleTransaction(false);
        processEngineConfiguration.setJpaCloseEntityManager(false);

        StrongUuidGenerator idGenerator = new StrongUuidGenerator();
        processEngineConfiguration.setIdGenerator(idGenerator);

        ArrayList<BpmnParseHandler> handlers = new ArrayList<BpmnParseHandler>();
        handlers.add(new HistoryHandler());
        handlers.add(new TaskHandler());
        processEngineConfiguration.setPostBpmnParseHandlers(handlers);

        processEngine = processEngineConfiguration.buildProcessEngine();

        // Initialize the Custom Query Utils
        final CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
        CustomQueryHelper.initialize(commandExecutor);

        return processEngine;
    }

    @Override
    public void ungetProcessEngine() {
        processEngine.close();
    }

    @Override
    public int getPrecedence() {
        return 100;
    }
   
    public TransactionManager getTransactionManager() throws Exception {
        return (TransactionManager) new InitialContext().lookup("java:jboss/TransactionManager");
     }


I am using activiti 12.1. Can anyone help me with the configuration?? Is something wrong??

Thank you!!!!
2 REPLIES 2

trademak
Star Contributor
Star Contributor
Can you post the code where the error happens and the stack trace?

Best regards,

yahekia
Champ in-the-making
Champ in-the-making
Hello trademark,

the problem was in:

pe.getRuntimeService().getVariable(delegateTask.getExecutionId(), TaskPropertiesKind.DOSSIER_ID.getValue())

At this moment I have solved the issue by upgrading to activiti 14 and adding to my persistence.xml the property:

<property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform" />

So for my enviroment:

Jboss 7.1 + EJB + Activiti 14 CDI + JPA Variable + JTA + XATransaction

The only way to make it works has been benn with the configuration above and adding the Jboss property. Same configurations doesn't works in Activiti 12.1.

Thank you for your answer