7 Replies Latest reply on Jul 30, 2007 7:42 PM by Troy Sellers

    Cannot save process instance? (from a NEWBIE!!)

    Troy Sellers Newbie

      Hi.

      I am trying to get a simple process deployed into a web application just to get started with jBPM.

      The process archive deploys into the database fine, and first time around I can create a process instance and then save it. However, when i create a process instance for a second time (I might be making a fundamental error here) I cannot save it again.

      Offending code

       public ActionForward execute(ActionMapping pMapping,
       ActionForm pActionForm, HttpServletRequest pRequest,
       HttpServletResponse pResponse) throws Exception {
      
       // the configuration instance is retrieved in a static block in this class
       // using the default jbpm.cfg.xml
       JbpmConfiguration cfg = JbpmUtil.getJbpmConfiguration();
       JbpmContext ctx = cfg.createJbpmContext();
      
       try {
       if (log.isDebugEnabled()) {
       log.debug("Creating a JBPM Process");
       }
      
       GraphSession graphSession = ctx.getGraphSession();
      
       ProcessDefinition processDefinition = graphSession.findLatestProcessDefinition("ProposalToOrder");
      
       if( processDefinition != null ) {
       log.info("Process Definition is ["+processDefinition.getName()+"/"+processDefinition.getVersion()+"/"+processDefinition.getId()+"]");
      
       log.info("Creating process instance");
       // create new process instance
       ProcessInstance processInstance = processDefinition.createProcessInstance();
       processInstance.signal();
       // attempt to save causes SQL constraint violation ?? (second pass only)
       ctx.save(processInstance);
       }
      
      
       } catch (Exception e) {
       return pMapping.findForward(ApplicationConstants.FORWARD_SYSTEM_ERROR);
       } finally {
       ctx.close();
       }
       return pMapping.findForward("success");
       }
      


      using process definition
      <?xml version="1.0" encoding="UTF-8"?>
      
      <process-definition
       xmlns="urn:jbpm.org:jpdl-3.2" name="ProposalToOrder">
       <start-state name="beginState">
       <transition name="transitionToTask" to="firstTask"></transition>
       </start-state>
       <end-state name="endState"></end-state>
       <task-node name="firstTask">
       <transition name="transitionToDecision" to="decisionYesNo"></transition>
       </task-node>
       <decision name="decisionYesNo">
       <transition name="No" to="NoState"></transition>
       <transition name="Yes" to="endState"></transition>
       </decision>
       <state name="NoState">
       <transition name="goToEnd" to="endState"></transition>
       </state>
      </process-definition>
      


      incredibly frustrating stack trace...

      2007-07-30 14:09:08,081 INFO [STDOUT] Hibernate:
      /* insert org.jbpm.graph.exe.ProcessInstance
      */ insert
      into
      JBPM_PROCESSINSTANCE
      (VERSION_, KEY_, START_, END_, ISSUSPENDED_, PROCESSDEFINITION_, ROOTTOKEN_, SUPERPROCESSTOKEN_, ID_)
      values
      (?, ?, ?, ?, ?, ?, ?, ?, ?)
      2007-07-30 14:09:08,091 DEBUG [org.hibernate.jdbc.AbstractBatcher] Executing batch size: 1
      2007-07-30 14:09:08,101 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
      2007-07-30 14:09:08,101 DEBUG [org.hibernate.util.JDBCExceptionReporter] Could not execute JDBC batch update [/* insert org.jbpm.graph.exe.ProcessInstance */ insert into JBPM_PROCESSINSTANCE (VERSION_, KEY_, START_, END_, ISSUSPENDED_, PROCESSDEFINITION_, ROOTTOKEN_, SUPERPROCESSTOKEN_, ID_) values (?, ?, ?, ?, ?, ?, ?, ?, ?)]
      java.sql.BatchUpdateException: ORA-00001: unique constraint (OES_JBPM.SYS_C0010738) violated

      at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:342)
      at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10656)
      at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
      at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
      at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:91)
      at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:86)
      at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:171)
      at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2048)
      at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2427)
      at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:51)
      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(AbstractFlushingEventListener.java:297)
      at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
      at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
      at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
      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.salestech.action.CreateProcessAction.execute(Unknown Source)
      at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
      at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
      at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
      at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      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.java:664)
      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)
      2007-07-30 14:09:08,101 WARN [org.hibernate.util.JDBCExceptionReporter] SQL Error: 1, SQLState: 23000
      2007-07-30 14:09:08,111 ERROR [org.hibernate.util.JDBCExceptionReporter] ORA-00001: unique constraint (OES_JBPM.SYS_C0010738) violated

      2007-07-30 14:09:08,111 WARN [org.hibernate.util.JDBCExceptionReporter] SQL Error: 1, SQLState: 23000
      2007-07-30 14:09:08,111 ERROR [org.hibernate.util.JDBCExceptionReporter] ORA-00001: unique constraint (OES_JBPM.SYS_C0010738) violated


      Can anyone help here? I assume that I can create to process instances from the same process definition?? I have attempted this in a number of different ways, examples found in package documentation, wiki and elsewhere on the web.. in all cases this same behaviour occurs.

      Is the process definition incomplete? I thought to leave it this simple for starters would be easier to get this going first time... seems i was wrong about that too :-)
      I am pretty stuck now as I don't really know where to go from here.

      Cheers,
      Troy