1 2 Previous Next 17 Replies Latest reply on May 17, 2012 8:46 AM by srikanthvege1

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

    prakashp5562

      When I create a process instance using “start process” option from process console, I am able to see that instance under ProcessOverview ~ Process instance

       

      When I create the same process through a console application using “Java code”, the process instance does not show up in Process Overview ~ Process instance.  But the process has started as I can go to the tasks for that particular user & the tasks show up over there.

       

      Any help would be appreciated.

       

      Thanks

        • 1. Re: jBPM processes started from Java code dont show up in jBPM process console
          calca

          Hey,

           

          How are you starting the process from java code? Could you please paste the code you are using?

           

          Jbpm console looks the processes in history logs database (http://docs.jboss.org/jbpm/v5.1/userguide/ch07.html#d0e2836)

           

          So make sure you are attaching the logger to the ksession:


          JPAWorkingMemoryDbLogger logger = new JPAWorkingMemoryDbLogger(ksession);

           

          Hope this helps

           

          Demian    

          • 2. Re: jBPM processes started from Java code dont show up in jBPM process console
            prakashp5562

            Thanks Demian.

            I added the JPAWorkingMemoryDBLogger along with the persistence.xml, but sill not showing up in the process console.

            The process is started w/o exceptions as I can see the user tasks in the process console, but not the process instances.

             

            Below is my code.

             

            private void StartWorkflow( String messageToPublish, String Identifier, String tag )

                      {

                                try

                                {

                                          KnowledgeBase kbase = readKnowledgeBase();

                                          StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

                                          JPAWorkingMemoryDbLogger dbLogger = new JPAWorkingMemoryDbLogger(ksession);

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

                                          //start a new process instance

             

             

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

                                          // start a new process instance

                                          Map<String, Object> params = new HashMap<String, Object>();

                                          params.put("reason", "Registration");

                                          params.put("patientXml", messageToPublish);

                                          params.put("identifier", Identifier);

                                          params.put("tag", tag);

             

             

             

                                          ksession.addEventListener(new com.ge.edadmit.rest.RegistrationEventListener());

                                          ksession.startProcess("com.ge.edadmit.EdAdmitWorkflow", params);

             

                                          dbLogger.dispose();

                                          //dblogger.

                                          logger.close();

                                }

                                catch (Throwable t)

                                {

                                          System.out.println(t.getMessage());

                                      t.printStackTrace();

                                }

                      }

            • 3. Re: jBPM processes started from Java code dont show up in jBPM process console
              calca

              mmm

               

              do you have  in your persistence.xml ProcessInstanceLog, NodeInstanceLog and VariableInstanceLog mapped?

               

              Do do you see information about your processes in these tables in database?

               

              Demian

              • 4. Re: jBPM processes started from Java code dont show up in jBPM process console
                prakashp5562

                Below is the persistence.xml & the tables in the database.  Is this the right database

                 

                Which tables should I look for.tables.png

                 

                 

                <?xml version="1.0" encoding="UTF-8" standalone="yes"?>

                 

                 

                <persistence

                 

                 

                  version="1.0"

                 

                 

                  xsi:schemaLocation=

                 

                 

                    "http://java.sun.com/xml/ns/persistence

                 

                 

                     http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd

                 

                 

                     http://java.sun.com/xml/ns/persistence/orm

                 

                 

                     http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"

                 

                 

                  xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"

                 

                 

                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                 

                 

                  xmlns="http://java.sun.com/xml/ns/persistence">

                 

                 

                 

                 

                 

                 

                  <persistence-unit name="org.jbpm.persistence.jpa">

                 

                 

                    <provider>org.hibernate.ejb.HibernatePersistence</provider>

                 

                 

                    <jta-data-source>jdbc/processInstanceDS</jta-data-source>

                 

                 

                    <class>org.drools.persistence.session.SessionInfo</class>

                 

                 

                    <class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>

                 

                 

                    <class>org.jbpm.persistence.processinstance.WorkItemInfo</class>

                 

                 

                    <class>org.jbpm.process.audit.ProcessInstanceLog</class>

                 

                 

                    <class>org.jbpm.process.audit.NodeInstanceLog</class>

                 

                 

                    <class>org.jbpm.process.audit.VariableInstanceLog</class>

                 

                 

                 

                 

                 

                 

                    <properties>

                 

                 

                      <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>

                 

                 

                      <property name="hibernate.max_fetch_depth" value="3"/>

                 

                 

                      <property name="hibernate.hbm2ddl.auto" value="update"/>

                 

                 

                      <property name="hibernate.show_sql" value="true"/>

                 

                 

                      <property name="hibernate.transaction.manager_lookup_class"

                 

                 

                                value="org.hibernate.transaction.BTMTransactionManagerLookup"/>

                 

                 

                    </properties>

                 

                 

                  </persistence-unit>

                 

                 

                </persistence>

                • 5. Re: jBPM processes started from Java code dont show up in jBPM process console
                  jsolanu

                  I'm pretty much having the same issue, downloaded today from http://sourceforge.net/projects/jbpm/files/latest/download?source=files

                   

                  Ran the demo setup and script referenced on http://docs.jboss.org/jbpm/v5.1/userguide/ch03.html

                   

                  Tried to run the example in section 3.4 of the user guid and nothing shows up under the Process Instances, Process Instance, or Human Task View in eclipse, though they are listed in the console discussed in section 3.5.

                  • 6. Re: jBPM processes started from Java code dont show up in jBPM process console
                    calca

                    I cannot see the image, it is small..

                     

                    Do you see the processes you started from java doc in ProcessInstanceLog table?

                    • 7. Re: jBPM processes started from Java code dont show up in jBPM process console
                      prakashp5562

                      Sorry but I dont see the ProcessInstanceLog table.

                      I opened Hypersonic query analyzer & see all JBM tables, no JBPM tables are seen

                      • 8. Re: jBPM processes started from Java code dont show up in jBPM process console
                        calca

                        How is your connection string to h2?

                        • 9. Re: jBPM processes started from Java code dont show up in jBPM process console
                          prakashp5562

                          I did not do anything specific.

                          whats by default.

                          • 10. Re: jBPM processes started from Java code dont show up in jBPM process console
                            prakashp5562

                            from my hsqldb-ds.xml, the connection url is

                                  <connection-url>jdbc:hsqldb:${jboss.server.data.dir}${/}hypersonic${/}localDB</connection-url>

                            But this db does not have any JBPM tables.

                            • 11. Re: jBPM processes started from Java code dont show up in jBPM process console
                              swiderski.maciej

                              Console is retrieving process instances from history tables using jbpm-bam module. It is configured via hibernate.cfg.xml. So it can be either inside jbpm-bam-{version}.jar file or in gwt-console-server.war file. It contains connection definition to the data base to retrieve history information.

                               

                              So you could verify that it has right data, by default it uses H2 db instead of hsql.

                               

                              HTH

                              • 12. Re: jBPM processes started from Java code dont show up in jBPM process console
                                mbraud

                                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é

                                • 13. Re: jBPM processes started from Java code dont show up in jBPM process console
                                  swiderski.maciej

                                  Most likely your persistence.xml file has property hibernate.hbm2ddl.auto set to create or create-drop which means that whenever you build EntityManagerFactory will reset your data base by rebuilding schema. Change that to update and your problem will disappear (in all described cases).

                                   

                                  HTH

                                  • 14. Re: jBPM processes started from Java code dont show up in jBPM process console
                                    mbraud

                                    Of course, the Hibernate settings! I should have thought about that really...

                                    Yep, that solved the problem.

                                    Thanks a lot for the help and sorry for the trivial question.

                                     

                                    Maïté

                                    1 2 Previous Next