1 2 Previous Next 16 Replies Latest reply on Nov 28, 2010 10:33 AM by btayo1

    How to Handle Process Execution History

    brado

      I am using jBPM 3.1.1. The user guide states regarding persistence of process instances:

      "The main purpose of persistence is to store process executions during wait states."

      This suggests pretty strongly that the purpose of persistence in jBPM is supporting the runtime execution of processes. However, I also want a history of all processes executed. Looking at the jBPM datbase schema, it appears that the JBPM_PROCESSINSTANCE table is probably the only candidate for this, and I'm guessing that's the same table regular persistence mentioned in the user guide writes to.

      Perhaps I'm just overlooking it, but is there a generally accepted means of retrieving a history of all processes executed? If not, how is everyone else handling this...writing to your own history table I presume?

      Thanks for your help.

      Brad

        • 1. Re: How to Handle Process Execution History
          kukeltje

          Brad,

          To get these kinds of overviews is still one of the ommissions in jBPM. The API does not have anything for this (yet), neither does the webapp.


          We (the company I work for) do not use specific tables for this.

          • 2. Re: How to Handle Process Execution History
            brado

            Ronald,

            Ok, understood. Thanks for the answer. Supposing I were to contribute a history table to the db schema, how in your view would be the best way to handle writing history? Would it be best to add it as an automatic function done at the time a process instance is created, or leave it a manual function that can be optionally invoked on a process instance? For example, say with a saveHistory() method, where the instance is created in the table if it doesn't exist, and it is updated in the table if it already exists...

            What are your thoughts on this?

            Brad

            • 3. Re: How to Handle Process Execution History
              kukeltje

              Brad,

              There already is lots of logging. Adding another table for this is imo not the way to go. Can you indicate what you miss in the available jbpm_log table. (it contains lots, and lots of info)

              • 4. Re: How to Handle Process Execution History
                kukeltje

                Brad,

                There already is lots of logging. Adding another table for this is imo not the way to go. Can you indicate what you miss in the available jbpm_log table. (it contains lots, and lots of info)

                • 5. Re: How to Handle Process Execution History
                  brado

                  Ronald,

                  Yeah, I think for now I'd be happy to just see the data from the JBPM_LOG table -- problem is I don't seem to be getting any data populated in the table. The user guide states:

                  "Various kinds of logs are generated by jBPM : graph execution logs, context logs and task management logs.
                  ...
                  The LoggingInstance will collect all the log entries. When the ProcessInstance is saved, all the logs in the LoggingInstance will be flushed to the database. "

                  I have a business process deployed to my server, and I'm getting the process definition, creating a process instance, and immediately saving the process instance to the database. Then I execute my business process. Following, I immediately save my process instance again. I am not seeing anything saved to my JBPM_PROCESSINSTANCE or JBPM_LOG table.

                  Here's basically the code block I'm using:

                  JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
                  GraphSession graphSession = jbpmContext.getGraphSession();
                  ProcessDefinition processDefinition = graphSession.findLatestProcessDefinition("MyProcess");
                  ProcessInstance processInstance = new ProcessInstance(processDefinition);
                  jbpmContext.save(processInstance);
                  Token token = processInstance.getRootToken();
                  token.signal();
                  jbpmContext.save(processInstance);
                  


                  I can trace through this in the debugger, and it executes fine, and doesn't either throw exceptions or output any errors to the JBoss log. In addition, it appears I'm able to retrieve my process definition fine from the database, so that should demonstrate that communication with the database is working.

                  Any ideas?

                  Brad

                  • 6. Re: How to Handle Process Execution History
                    kukeltje
                    • 7. Re: How to Handle Process Execution History
                      brado

                      I followed the instructions in these documents. As instructed in the links you referenced, I added the following to my jbpm.cfg.xml file and rebuilt / deployed my sar:

                      <jbpm-context>
                       <!-- other services -->
                       <service name="logging" factory="org.jbpm.logging.db.DbLoggingServiceFactory" />
                      </jbpm-context>
                      


                      Upon doing this, JBoss now gives the following error (which causes more errors) on startup:

                      2006-07-12 17:07:06,906 DEBUG [org.jbpm.configuration.JbpmContextInfo] creating jbpm context with service factories '[logging]'
                      2006-07-12 17:07:06,906 DEBUG [org.jbpm.JbpmContext] creating JbpmContext
                      2006-07-12 17:07:06,906 DEBUG [org.jbpm.msg.command.CommandExecutorThread] command 'null' threw exception. rolling back transaction
                      org.jbpm.configuration.ConfigurationException: no messaging service available
                       at org.jbpm.msg.command.CommandExecutorThread.executeCommand(CommandExecutorThread.java:116)
                       at org.jbpm.msg.command.CommandExecutorThread.run(CommandExecutorThread.java:79)
                      2006-07-12 17:07:06,906 DEBUG [org.jbpm.JbpmContext] closing JbpmContext
                      2006-07-12 17:07:06,906 ERROR [org.jbpm.msg.command.CommandExecutorThread] java.lang.NullPointerException
                      


                      Have any idea how to rectify this problem?

                      Thanks for your help,

                      Brad

                      • 8. Re: How to Handle Process Execution History
                        brado

                        After further review, I think the links given may have left some important information out, in combination with possibly some confusing comments in the default jbpm.cfg.xml file. Anyway, I altered my jbpm.cfg.xml file once again, to be exactly the same as the default file (the reason I did this is that I think the default file may be getting overwritten with an empty jbpm.cfg.xml due to how the ant build script is working).

                        Anyway, I did this, and those changes to the jbpm.cfg.xml (the ones recommended in the links given and the ones I performed) build to the jbpm.sar.cfg.jar which is inside the sar file. After deploying this new sar, JBoss starts cleanly again. However, running the process and saving the process does not write anything to the JBPM_LOG table or the JBPM_PROCESSINSTANCE table. Both are still empty. So I guess I'm right back where I started. Here's my current jbpm.cfg.xml file:

                        <jbpm-configuration>
                        
                         <!--
                         The default configurations can be found in org/jbpm/default.jbpm.cfg.xml
                         Those configurations can be overwritten by putting this file called
                         jbpm.cfg.xml on the root of the classpath and put in the customized values.
                         -->
                        
                         <jbpm-context>
                         <service name="persistence"
                         factory="org.jbpm.persistence.db.DbPersistenceServiceFactory" />
                         <service name="message"
                         factory="org.jbpm.msg.db.DbMessageServiceFactory" />
                         <service name="scheduler"
                         factory="org.jbpm.scheduler.db.DbSchedulerServiceFactory" />
                         <service name="logging"
                         factory="org.jbpm.logging.db.DbLoggingServiceFactory" />
                         <service name="authentication"
                         factory="org.jbpm.security.authentication.DefaultAuthenticationServiceFactory" />
                         </jbpm-context>
                        
                         <!-- configuration resource files pointing to default configuration files in jbpm-{version}.jar -->
                         <string name="resource.hibernate.cfg.xml" value="hibernate.cfg.xml" />
                         <string name="resource.business.calendar"
                         value="org/jbpm/calendar/jbpm.business.calendar.properties" />
                         <string name="resource.default.modules"
                         value="org/jbpm/graph/def/jbpm.default.modules.properties" />
                         <string name="resource.converter"
                         value="org/jbpm/db/hibernate/jbpm.converter.properties" />
                         <string name="resource.action.types"
                         value="org/jbpm/graph/action/action.types.xml" />
                         <string name="resource.node.types"
                         value="org/jbpm/graph/node/node.types.xml" />
                         <string name="resource.parsers"
                         value="org/jbpm/jpdl/par/jbpm.parsers.xml" />
                         <string name="resource.varmapping"
                         value="org/jbpm/context/exe/jbpm.varmapping.xml" />
                        
                         <long name="jbpm.msg.wait.timout" value="5000" singleton="true" />
                         <int name="jbpm.byte.block.size" value="1024" singleton="true" />
                         <string name="mail.smtp.host" value="localhost" />
                         <bean name="jbpm.task.instance.factory"
                         class="org.jbpm.taskmgmt.impl.DefaultTaskInstanceFactoryImpl"
                         singleton="true" />
                         <bean name="jbpm.variable.resolver"
                         class="org.jbpm.jpdl.el.impl.JbpmVariableResolver" singleton="true" />
                         <bean name="jbpm.mail.address.resolver"
                         class="org.jbpm.identity.mail.IdentityAddressResolver"
                         singleton="true" />
                        
                        </jbpm-configuration>
                        


                        Help!

                        Thanks,

                        Brad

                        • 9. Re: How to Handle Process Execution History
                          brado

                          I must really be missing something here. I traced into the jbpmContext.save(processInstance) call, and the call stack eventually arrives at the following method in the org.jbpm.svc.save.CheckUnpersistableVariablesOperation class:

                          public void save(ProcessInstance processInstance, JbpmContext jbpmContext) {
                           Collection updatedVariableContainers = VariableContainer.getUpdatedVariableContainers(processInstance);
                           if (updatedVariableContainers!=null) {
                          
                           // loop over all updated variable containers
                           Iterator iter = updatedVariableContainers.iterator();
                           while (iter.hasNext()) {
                           VariableContainer variableContainer = (VariableContainer) iter.next();
                           Map variableInstances = variableContainer.getVariableInstances();
                           if (variableInstances!=null) {
                          
                           // loop over all variable instances in the container
                           Iterator varInstancesIter = variableInstances.entrySet().iterator();
                           while (varInstancesIter.hasNext()) {
                           Map.Entry entry = (Map.Entry) varInstancesIter.next();
                           String name = (String) entry.getKey();
                           VariableInstance variableInstance = (VariableInstance) entry.getValue();
                          
                           // if the variable is of the unpersistable type... booom!
                           if (variableInstance instanceof UnpersistableInstance) {
                           Object value = variableInstance.getValue();
                           if (value!=null) {
                           throw new JbpmException("variable '"+name+"' in '"+variableContainer+"' contains '"+value+"': type '"+value.getClass().getName()+"' is unpersistable according to the jbpm.varmapping.xml configuration");
                           } else {
                           throw new JbpmException("variable '"+name+"' in '"+variableContainer+"' was created with a non persistable value");
                           }
                           }
                           }
                           }
                           }
                           }
                           }
                          


                          Tracing through this code, I don't see where or how either log data or the process instance is ever saved to the database. I must be missing it, but where in this code (or in any code) is the actual save made to the database? Again, I'm using jbpm3.1.1.

                          Thanks for your help...

                          Brad

                          • 10. Re: How to Handle Process Execution History
                            brado

                            Is there anyone who has gotten logging and saving process instances to the database (specifically populating the JBPM_LOG and JBPM_PROCESSINSTANCE tables) working in jBPM 3.1.1? If so, could you post your jbpm.cfg.xml file, so I can rule out a configuration error in mine? I'd really appreciate it. Any tips you can give on getting this working would be greatly appreciated too.

                            Thanks,

                            Brad

                            • 11. Re: How to Handle Process Execution History
                              cpob

                              I get tons of logs in my log output, and I didn't have to do much.

                              <jbpm-configuration>
                               <jbpm-context>
                               <service name="persistence" factory="org.jbpm.persistence.db.DbPersistenceServiceFactory" />
                               <service name="message" factory="org.jbpm.msg.db.DbMessageServiceFactory" />
                               <service name="scheduler" factory="org.jbpm.scheduler.db.DbSchedulerServiceFactory" />
                               <service name="logging" factory="org.jbpm.logging.db.DbLoggingServiceFactory" />
                               <service name="authentication" factory="org.jbpm.security.authentication.DefaultAuthenticationServiceFactory" />
                               </jbpm-context>
                              </jbpm-configuration>




                              • 12. Re: How to Handle Process Execution History
                                brado

                                cpob,

                                Thank you very much for the reply. I have the same text as you in my jbpm.cfg.xml file. So if it isn't a matter of what's in the config file itself, perhaps it is an issue of where the file is located.

                                Within my jbpm.sar file, there is a file called jbpm.sar.cfg.jar, and inside of it, in its root, is this jbpm.cfg.xml file. Is this consistent with where your jbpm.cfg.xml file is?

                                Where is your jpbm.cfg.xml file in your archive?

                                Thanks again...

                                Brad

                                • 13. Re: How to Handle Process Execution History
                                  brado

                                  Problem solved. The problem was apparently that I had no jbpmContext.close() operation, so although everything was executing properly, no commit was ever done on the SQL transactions performed on the context.

                                  However, this begs another question, which is directly applicable to my code that I posted earlier in this thread. What if I want to perform more than one jbpmContext.save() operation, and I want the first save operation committed prior to the next one being committed? If the only way to commit is using the close() method, do I have to close() the jbpmContext and then recreate another one?

                                  Thanks...

                                  Brad

                                  • 14. Closing the Jbpm Context
                                    bert.w

                                    dear all,

                                    I am having the same problem: No process instances showing up in the database. However, i cannot get the solution of using jbpmContext.close() working, as i am using jbpm integrated with Spring.
                                    Can anyone tell me how i can close the Jbpm Context when using the JbpmTemplate from spring?

                                    Using JbpmContext.getCurrentJbpmContext().close() doesn't seem to work for me, as it always returns null.

                                    Or how can i use the protected method getContext() from JbpmTemplate?

                                    thanks!
                                    BERT

                                    1 2 Previous Next