5 Replies Latest reply on Jan 14, 2008 8:01 AM by Jan-Kees van Andel

    Exception while executing SubProcess

    sulakshana injumuri Newbie

      Hi.,
      Iam trying to executing the below program in which ProcessState node is used.

      <process-definition
       xmlns="" name="MainProcess">
       <start-state name="start">
       <transition name="" to="state1"></transition>
       </start-state>
       <state name="state1">
       <transition name="" to="process1"></transition>
       </state>
       <end-state name="end1"></end-state>
       <process-state name="process1">
       <sub-process name="ChildProcess"></sub-process>
       <transition name="" to="end1"></transition>
       </process-state>
      </process-definition>

      And the childProcess is
      <process-definition
       xmlns="" name="ChildProcess">
       <start-state name="start">
       <transition name="" to="ChildProcessState"></transition>
       </start-state>
       <state name="ChildProcessState">
       <event type="node-enter">
       <action name="Action" class="com.iton.handlers.ChildProcessAction"></action>
       </event>
       <transition name="" to="end1"></transition>
       </state>
       <end-state name="end1"></end-state>
      </process-definition>
      

      The Program which iam trying to Execute is
       JbpmConfiguration jbpmConfiguration =JbpmConfiguration.parseResource("hibernate.cfg");
       JbpmContext jbpmContext=jbpmConfiguration.createJbpmContext();
       try{
      // parsing sub process
       ProcessDefinition subProcessDefinition = ProcessDefinition.parseXmlResource("ChildProcess/processdefinition.xml");
       System.out.println("Entered into Subproceess");
       jbpmContext.deployProcessDefinition(subProcessDefinition);
       System.out.println("subproceess Deployed ");
       ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource("MainProcess/processdefinition.xml");
       System.out.println("Entered into Main Process");
       jbpmContext.deployProcessDefinition(processDefinition);
       System.out.println("Main proceess deployed");
      
       ProcessInstance subProcessInstance = subProcessDefinition.createProcessInstance();
       jbpmContext.save(subProcessInstance);
       System.out.println("subproceess saved ");
       //parsing parent process
       ProcessInstance processInstance = processDefinition.createProcessInstance();
       jbpmContext.save(processInstance);
       System.out.println("Main Process Saved");
      
       System.out.println(" a: "+ processInstance.getRootToken().getNode().getName());
       processInstance.signal();
       System.out.println(" b: "+ processInstance.getRootToken().getNode().getName());
       System.out.println("going to Process State now");
       processInstance.signal();
       }
       catch(Exception e)
       {e.printStackTrace();}
       finally{
       jbpmContext.close();
       }
      

      But I found the following Exception while executing the above code.
      14:25:15,057 WARN [JDBCExceptionReporter] SQL Error: 1, SQLState: 23000
      14:25:15,057 ERROR [JDBCExceptionReporter] ORA-00001: unique constraint (JBPM.SYS_C007079) violate
      
      14:25:15,057 WARN [JDBCExceptionReporter] SQL Error: 1, SQLState: 23000
      14:25:15,057 ERROR [JDBCExceptionReporter] ORA-00001: unique constraint (JBPM.SYS_C007079) violate
      
      14:25:15,057 ERROR [AbstractFlushingEventListener] Could not synchronize database state with sessi
      org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
       at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
       at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
       at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:249)
       at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:92)
       at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:87)
       at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:218)
       at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.ja
       at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.ja
       at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:52)
       at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
       at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
       at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
       at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushing
       at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java
       at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
       at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
       at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
       at org.jbpm.persistence.db.DbPersistenceService.commit(DbPersistenceService.java:253)
       at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:211)
       at org.jbpm.svc.Services.close(Services.java:222)
       at org.jbpm.JbpmContext.close(JbpmContext.java:139)
       at com.iton.servlets.TestProcessState.doGet(TestProcessState.java:90)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.j
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Ht
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: java.sql.BatchUpdateException: ORA-00001: unique constraint (JBPM.SYS_C007079) violated
      
       at oracle.jdbc.dbaccess.DBError.throwBatchUpdateException(DBError.java:441)
       at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:337
       at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
       at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
       ... 39 more
      

      And I found that exceptiom is araised when it entered in to subprocess and the statements in childprocess action are printed on console.Also processdefinition and processinstances are saved in the db while executing.

      Please Some one Help me to solve this Problem.

      Thank you.

        • 1. Re: Exception while executing SubProcess
          Martin Weiler Apprentice

          why do you explicitly create an instance of the sub-process?

          • 2. Re: Exception while executing SubProcess
            sulakshana injumuri Newbie

            Thank u Martin.I could able to solve that exception now.
            but now iam getting NullPointerException.
            Below is the modified code and Exception .

            JbpmConfiguration jbpmConfiguration =JbpmConfiguration.parseResource("hibernate.cfg");
             JbpmContext jbpmContext=jbpmConfiguration.createJbpmContext();
             try{
            // parsing sub process
             ProcessDefinition subProcessDefinition = ProcessDefinition.parseXmlResource("ChildProcess/processdefinition.xml");
             jbpmContext.deployProcessDefinition(subProcessDefinition);
             System.out.println("subproceess Deployed ");
             ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource("MainProcess/processdefinition.xml");
             jbpmContext.deployProcessDefinition(processDefinition);
             System.out.println("Main proceess deployed");
            
             ProcessInstance processInstance = processDefinition.createProcessInstance();
             System.out.println(" a: "+ processInstance.getRootToken().getNode().getName());
             processInstance.signal();
             System.out.println(" b: "+ processInstance.getRootToken().getNode().getName());
             System.out.println("going to Process State now");
             processInstance.signal();
             System.out.println(" c: "+ processInstance.getRootToken().getNode().getName());
             System.out.println("reached to process State Now");
            
            
             System.out.println(" : "+ processInstance.getRootToken().getNode().getName());
            
             processInstance.signal();// i expect , signal to end node of main process here. but i got the below exception.
             System.out.println(" d: "+ processInstance.getRootToken().getNode().getName());
            
             }
             catch(Exception e)
             {e.printStackTrace();}
             finally{
             jbpmContext.close();
             }
            

            And the exception is
             java.lang.NullPointerException
             at org.jbpm.graph.node.ProcessState.leave(ProcessState.java:197)
             at org.jbpm.graph.exe.Token.signal(Token.java:194)
             at org.jbpm.graph.exe.Token.signal(Token.java:139)
             at org.jbpm.graph.exe.ProcessInstance.signal(ProcessInstance.java:251)
             at com.iton.servlets.TestProcessState.doGet(TestProcessState.java:110)
             at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
             at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
             at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
             at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
             at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
             at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
             at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
             at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
             at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
             at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
             at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
             at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
             at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.ja
            
             at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
             at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
             at java.lang.Thread.run(Thread.java:595)
            


            Plz tell me whats wrong in my code??

            • 3. Re: Exception while executing SubProcess
              Jan-Kees van Andel Newbie

              I'm having the same problem. Does somebody have a solution for this problem?

              Apart from some names, my process definition looks the same as the one posted above.

              • 4. Re: Exception while executing SubProcess
                Jan-Kees van Andel Newbie

                 

                "jkva" wrote:
                I'm having the same problem. Does somebody have a solution for this problem?

                Apart from some names, my process definition looks the same as the one posted above.

                With problem, I mean the NullPointerException.

                • 5. Re: Exception while executing SubProcess
                  Jan-Kees van Andel Newbie

                  I've found a possible solution for the NPE. I don't think it's a best practice, but at the moment it works.

                  The fix is manually creating an instance of the sub process and then manually creating a token, like in the following snippet.

                  token.signal();
                  ProcessInstance subProcessInstance = token.createSubProcessInstance(subProcessDefinition);
                  Token subToken = subProcessInstance.getRootToken();
                  subToken.signal();
                  subToken.signal();
                  


                  However, it doesn't feel that good actually. It looks like I'm doing jBPM's job.