JBoss Community

Re: jBPM processes started from Java code dont show up in jBPM process console

created by Maïté Braud in jBPM - View the full discussion

Hi

 

I've got a similar issue except that in my case, processes started from java simply reset entries in my database.

I have only one process available. The first step in this process is a human task.

 

If I start 2 process instances from the jBPM console, both process instances appear in the "Process Overview" tab and they also appear in the database (I'm persisting PROCESSINSTANCEINFO, PROCESSINSTANCELOG, SESSIONINFO, VARIABLEINSTANCELOG, WORKITEMINFO and NODEINSTANCELOG in a H2 DB).

 

If I start the same process from the java code, my 2 previous process instances disappear (both from the console and the database which is consistent) and get replaced by the new process instance.

If I start another process instance from the java code, it replaces the previous one so that I can never have more than 2 process instances started from my java code.

 

Here is my java code:

 

        EntityManagerFactory emf = Persistence.createEntityManagerFactory( "org.jbpm.persistence.jpa" );

        Environment env = KnowledgeBaseFactory.newEnvironment();

        env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);

        env.set(EnvironmentName.TRANSACTION_MANAGER, TransactionManagerServices.getTransactionManager());

        env.set( EnvironmentName.GLOBALS, new MapGlobalResolver() );

 

        KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

        kbuilder.add(ResourceFactory.newClassPathResource(ACCESS_WORKFLOW_FILE), ResourceType.BPMN2 );

        KnowledgeBase kbase = kbuilder.newKnowledgeBase();

        StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env);

 

        JPAWorkingMemoryDbLogger dbLogger = new JPAWorkingMemoryDbLogger(ksession);

        KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test");

        ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new CommandBasedWSHumanTaskHandler(ksession));

       

        ksession.startProcess(ACCESS_WORKFLOW_ID, new HashMap());

 

        dbLogger.dispose();

        logger.close();

 

 

Also I forgot to mention it but I'm deploying jBPM 5.1 on Tomcat 6 and I'm not using Guvnor but simply a directory specified in "-Djbpm.console.directory".

 

I've also noted some strange behaviour where my process instances also seem to be reset everytime I restart tomcat. The entries remain in the DB after I shutdown Tomcat and they also remain in it once I've restarted Tomcat and logged in the jBPM console again but the moment I go to the "Process Overview" tab and jBPM reloads the process definition, all process instances disappear from my DB.

 

I think that I'm missing something important here but I don't know what.

Any help would be greatly appreciated

 

Maïté

Reply to this message by going to Community

Start a new discussion in jBPM at Community