AnsweredAssumed Answered

Problem with CdiJtaProcessEngineConfiguration

Question asked by yahekia on Nov 4, 2013
Latest reply on Nov 5, 2013 by yahekia
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!!!!

Outcomes