1 2 Previous Next 21 Replies Latest reply on Dec 22, 2010 6:34 AM by Harry P.

    JBPM Timer Problem

    Danny Shaul Newbie

      Hi
      I try to creater simple flow including Timer:

      <process-definition name="testprocess3">
      
       <start-state name='start'>
       <transition to='wait' />
       </start-state>
      
       <state name='wait'>
       <timer name='reminder'
       duedate='5 seconds'
       repeat='5 seconds'
       transition='time out'>
       <action class=MyActionHandler' />
       </timer>
       <transition to='wait2'/>
       </state>
      
       <state name='wait2'>
       <transition to='end'/>
       </state>
      
       <end-state name='end' />
      </process-definition>


      And run it from My Test class as follows:

      public void processTimer() {
      
       JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
       try {
      
       GraphSession graphSession = jbpmContext.getGraphSession();
      
       ProcessDefinition processDefinition =
       graphSession.findLatestProcessDefinition("testprocess3");
      
       ProcessInstance processInstance =
       new ProcessInstance(processDefinition);
      
       Token token = processInstance.getRootToken();
       assertEquals("start", token.getNode().getName());
      
       token.signal();
      
       token.signal();
       }
       finally {
       jbpmContext.close();
       }
       }


      The action class is implemented as follows:

      public class MyActionHandler implements ActionHandler {
      
       public void execute(ExecutionContext executionContext) {
       System.out.println("Inside Action handler...");
       }
      }



      The first signal() advance from start to wait state which suppose to activate the Timer task every 5 seconds and run the Action class
      It looks the Timer is never activated at all.
      Any Idea why?
      How exactlly Timers works, is it forked from the main process?


      I add to jbpm.cfg.xml the following entries:

      <jbpm-configuration>
       <jbpm-context>
       <service name="persistence" factory="org.jbpm.persistence.db.DbPersistenceServiceFactory" />
       <service name="message" factory="org.jbpm.msg.db.DbMessageServiceFactory" />
       <service name="tx" factory="org.jbpm.tx.TxServiceFactory"/>
       <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" />
       <bean name="jbpm.job.executor" class="org.jbpm.job.executor.JobExecutor" singelton="true" />
      
      </jbpm-configuration>


        • 1. Re: JBPM Timer Problem
          Ronald van Kuijk Master

          you (at least) have a not defined transition name in the timer....

          • 2. Re: JBPM Timer Problem
            Danny Shaul Newbie

            I also move the transition from the definition:

            <state name='wait'>
             <timer name='reminder'
             duedate='5 seconds'
             repeat='5 seconds'
             <action class=MyActionHandler' />
             </timer>
             <transition to='wait2'/>
             </state>


            • 3. Re: JBPM Timer Problem
              Ronald van Kuijk Master

              and you miss a single quote before MyActionHandler

              • 4. Re: JBPM Timer Problem
                Ronald van Kuijk Master

                no, you need a timerservice running. Look at the testcases or the jbpm webconsole

                • 5. Re: JBPM Timer Problem
                  Danny Shaul Newbie

                  I read Chapter 5 in the Jboss docs regarding the web-deploy which contains and start the timer services ( http://docs.jboss.org/jbpm/v3/userguide/deployment.html#webapplication),

                  My application is based on Spring framework which runs with JBoss, and I alreay configured the JBPM as a context in the Spring, should it be a problem?

                  • 7. Re: JBPM Timer Problem
                    Martin Weiler Apprentice

                    If you don't deploy the standard jBPM which configures the JobExecutorServlet, I'd suggest to add the configuration of this servlet to your own applications web.xml. As indicated in the javadocs of JobExecutorServlet, add the following configuration

                    <web-app>
                     ...
                     <servlet >
                     <servlet-name>JobExecutorServlet</servlet-name>
                     <servlet-class>org.jbpm.job.executor.JobExecutorServlet</servlet-class>
                     <load-on-startup>1</load-on-startup>
                     </servlet>
                     <servlet-mapping >
                     <servlet-name>JobExecutorServlet</servlet-name>
                     <url-pattern>/jobexecutor</url-pattern>
                     </servlet-mapping>
                     ...
                     </web-app>


                    Best regards, Martin

                    • 8. Re: JBPM Timer Problem
                      Danny Shaul Newbie

                      I add the JobExecutorServlet to my configuration as mentiond and I get the following error while satrt up the application:

                      2007-05-03 15:18:00,328 ERROR [org.jbpm.job.executor.JobExecutorThread] exception in job executor thread. waiting 40000 milliseconds
                      org.hibernate.MappingException: invalid configuration
                      at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1411)
                      at org.hibernate.cfg.Configuration.configure(Configuration.java:1352)
                      at org.jbpm.db.hibernate.HibernateHelper.createConfiguration(HibernateHelper.java:91)
                      at org.jbpm.persistence.db.DbPersistenceServiceFactory.getConfiguration(DbPersistenceServiceFactory.java:69)
                      at org.jbpm.persistence.db.DbPersistenceServiceFactory.getSessionFactory(DbPersistenceServiceFactory.java:91)
                      at org.jbpm.persistence.db.DbPersistenceService.getSessionFactory(DbPersistenceService.java:94)
                      at org.jbpm.persistence.db.DbPersistenceService.getSession(DbPersistenceService.java:98)
                      at org.jbpm.persistence.db.DbPersistenceService.getJobSession(DbPersistenceService.java:352)
                      at org.jbpm.JbpmContext.getJobSession(JbpmContext.java:563)
                      at org.jbpm.job.executor.JobExecutorThread.acquireJobs(JobExecutorThread.java:109)
                      at org.jbpm.job.executor.JobExecutorThread.run(JobExecutorThread.java:56)
                      Caused by: org.xml.sax.SAXParseException: Element type "value" must be declared.
                      at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
                      at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
                      at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
                      at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
                      at org.apache.xerces.impl.dtd.XMLDTDValidator.handleStartElement(Unknown Source)
                      at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
                      at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
                      at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
                      at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
                      at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
                      at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
                      at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
                      at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
                      at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
                      at org.dom4j.io.SAXReader.read(SAXReader.java:465)
                      at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1408)
                      ... 10 more

                      • 9. Re: JBPM Timer Problem
                        Ronald van Kuijk Master

                        wel, that error is very explicit isn't it? There is something wrong with a value element in your hibernate config file. Check and correct that.

                        • 10. Re: JBPM Timer Problem
                          Danny Shaul Newbie

                          I know there is a problem with the hibernate.cfg.xml file but I wonder if it's my application configuration problem, I add the following entries relevant to hibernate config as documented:

                          <bean id="jbpmDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
                           <property name="driverClassName"><value>oracle.jdbc.driver.OracleDriver</value></property>
                           <property name="url"><value>jdbc:oracle:thin:@srv-ora:1521:orcl</value></property>
                           <!-- property name="username"><value>build</value></property>
                           <property name="password"><value>build</value></property -->
                           <property name="username"><value>jbpm</value></property>
                           <property name="password"><value>jbpm</value></property>
                           </bean>
                          
                           <!-- JBPM Hibernate SessionFactory -->
                           <bean id="jbpmSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
                           <property name="dataSource" ref="jbpmDataSource"/>
                           <property name="mappingLocations">
                           <value>classpath*:/org/jbpm/**/*.hbm.xml</value>
                           </property>
                          
                           <property name="hibernateProperties">
                           <props>
                           <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
                           <prop key="hibernate.cache.use_second_level_cache">false</prop>
                           <prop key="hibernate.cache.use_query_cache">false</prop>
                          
                           <prop key="hibernate.hbm2ddl.auto">update</prop>
                           </props>
                           </property>
                           </bean>


                          Nothing else

                          • 11. Re: JBPM Timer Problem
                            Danny Shaul Newbie

                            Yes it looks like hibernate cfg file problem, the only relevant entries related to hibernate is placed in applicationContext-jbpmhibernate.xml file is:

                            <bean id="jbpmDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
                             <property name="driverClassName"><value>oracle.jdbc.driver.OracleDriver</value></property>
                             <property name="url"><value>jdbc:oracle:thin:@srv-ora:1521:orcl</value></property>
                             <!-- property name="username"><value>build</value></property>
                             <property name="password"><value>build</value></property -->
                             <property name="username"><value>jbpm</value></property>
                             <property name="password"><value>jbpm</value></property>
                             </bean>
                            
                             <!-- JBPM Hibernate SessionFactory -->
                             <bean id="jbpmSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
                             <property name="dataSource" ref="jbpmDataSource"/>
                             <property name="mappingLocations">
                             <value>classpath*:/org/jbpm/**/*.hbm.xml</value>
                             </property>
                            
                             <property name="hibernateProperties">
                             <props>
                             <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
                             <prop key="hibernate.cache.use_second_level_cache">false</prop>
                             <prop key="hibernate.cache.use_query_cache">false</prop>
                            
                             <prop key="hibernate.hbm2ddl.auto">update</prop>
                             </props>
                             </property>
                             </bean>



                            And it well defined towards the hibernate jbpm dtd.

                            • 12. Re: JBPM Timer Problem
                              Danny Shaul Newbie

                              Somehow it seems the JBPM use it's default configuration files, as I described in the question, I map to my own cfg file as follows:

                              <bean id="jbmpConfigurationResource" class="org.springframework.core.io.ClassPathResource">
                               <constructor-arg type="java.lang.String" value="jbpm.cfg.xml"/>
                               </bean>


                              While in jbpm.cfg.xml I comment out the line:


                              But when debug the code it looks it uses the default configuration and use the hibernate.cfg.xml placed in the jar,
                              What I should do in that case?



                              • 13. Re: JBPM Timer Problem
                                Danny Shaul Newbie

                                I overcome the problems described above, now I get the following error:

                                2007-05-06 18:41:19,328 ERROR [org.jbpm.job.executor.JobExecutorThread] exception in job executor thread. waiting 5000 milliseconds
                                org.hibernate.HibernateException: hibernate.cfg.xml not found
                                 at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:147)
                                 at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1329)
                                 at org.hibernate.cfg.Configuration.configure(Configuration.java:1351)
                                 at org.jbpm.db.hibernate.HibernateHelper.createConfiguration(HibernateHelper.java:91)
                                 at org.jbpm.persistence.db.DbPersistenceServiceFactory.getConfiguration(DbPersistenceServiceFactory.java:69)
                                 at org.jbpm.persistence.db.DbPersistenceServiceFactory.getSessionFactory(DbPersistenceServiceFactory.java:91)
                                 at org.jbpm.persistence.db.DbPersistenceService.getSessionFactory(DbPersistenceService.java:94)
                                 at org.jbpm.persistence.db.DbPersistenceService.getSession(DbPersistenceService.java:98)
                                 at org.jbpm.persistence.db.DbPersistenceService.getJobSession(DbPersistenceService.java:352)
                                 at org.jbpm.JbpmContext.getJobSession(JbpmContext.java:563)
                                 at org.jbpm.job.executor.JobExecutorThread.acquireJobs(JobExecutorThread.java:109)
                                 at org.jbpm.job.executor.JobExecutorThread.run(JobExecutorThread.java:56)
                                




                                • 14. Re: JBPM Timer Problem
                                  Ronald van Kuijk Master

                                  I could state the obvious, but I won't. Instead, I refer you to the spring jbpm forum, since that is what you seem to be using. They can probably tell you how to configure the jobexecutor to use the same spring hibernate config.

                                  1 2 Previous Next