11 Replies Latest reply on Aug 19, 2009 6:32 PM by Ha Wa

    JBPM4.0 Oracle Parent Key Not Found Error

    sri r Newbie

      Environment:
      JBPM4.0
      Hibernate 3.3.1GA
      Database: Oracle 10

      When i try to create a process instance out of the following process definition, it fails with below error. The same when i run against hsql on my local it works fine. Only difference we have in oracle is the sequence are our own instead of assigned=native.

      ProcessDefinition:


      
      <?xml version="1.0" encoding="UTF-8"?>
      
      <process name="SimpleProcess" xmlns="http://jbpm.org/4.0/jpdl">
      
       <start g="20,20,48,48">
       <transition name="review1" to="review1" />
       </start>
      
       <task name="review1" g="96,16,127,52">
       <assignment-handler class="test.TaskHandler">
       </assignment-handler>
       <transition name="review2" to="review2" />
       </task>
      
       <task name="review2" g="96,16,127,52">
       <assignment-handler class="test.TaskHandler">
       </assignment-handler>
       <transition name="review3" to="review3" />
       </task>
      
       <task name="review3" g="96,16,127,52">
       <assignment-handler class="test.TaskHandler">
       </assignment-handler>
       <transition name="endstate" to="endstate" />
       </task>
      
       <end name="endstate" g="255,16,88,52" />
      
      </process>
      
      
      


      Error:

      
      Caused by: java.sql.BatchUpdateException: ORA-02291: integrity constraint (JBPM4.FK_HTI_HTASK) violated - parent key not found
      
       at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:343)
       at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10768)
       at com.p6spy.engine.logging.P6LogPreparedStatement.executeBatch(P6LogPreparedStatement.java:329)
       at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:294)
       at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
       at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
       ... 72 more
      
      
      
      



      Logs (I used p6spy driver to see values being passed)

      Hibernate: select * from ( select deployment1_.OBJNAME_ as col_0_0_, deployment1_.DEPLOYMENT_ as col_1_0_ from test.JBPM4_DEPLOYMENT deployment0_, test.JBPM4_DEPLOYPROP deployment1_, test.JBPM4_DEPLOYPROP deployment2_, test.JBPM4_DEPLOYPROP deployment3_ where deployment1_.KEY_='pdid' and deployment1_.DEPLOYMENT_=deployment0_.DBID_ and deployment2_.KEY_='pdkey' and deployment2_.OBJNAME_=deployment1_.OBJNAME_ and deployment2_.DEPLOYMENT_=deployment0_.DBID_ and deployment3_.KEY_='pdversion' and deployment3_.OBJNAME_=deployment1_.OBJNAME_ and deployment3_.DEPLOYMENT_=deployment0_.DBID_ and deployment2_.STRINGVAL_='SimpleProcess' order by deployment3_.LONGVAL_ desc ) where rownum <= ?
      
      Hibernate: select * from ( select deployment0_.DBID_ as DBID1_13_, deployment0_.DEPLOYMENT_ as DEPLOYMENT2_13_, deployment0_.OBJNAME_ as OBJNAME3_13_, deployment0_.KEY_ as KEY4_13_, deployment0_.STRINGVAL_ as STRINGVAL5_13_, deployment0_.LONGVAL_ as LONGVAL6_13_ from test.JBPM4_DEPLOYPROP deployment0_ where deployment0_.KEY_='pdid' and deployment0_.STRINGVAL_='SimpleProcess-1' ) where rownum <= ?
      
      Hibernate: select test.S_JBPM4_EXECUTION.nextval from dual
      
      Hibernate: insert into test.JBPM4_EXECUTION (DBVERSION_, ACTIVITYNAME_, PROCDEFID_, HASVARS_, NAME_, KEY_, ID_, STATE_, SUSPHISTSTATE_, PRIORITY_, HISACTINST_, PARENT_, INSTANCE_, SUPEREXEC_, SUBPROCINST_, CLASS_, DBID_) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'pvm', ?)
      
      Hibernate: select test.S_JBPM4_HIST_PROCINST.nextval from dual
      
      Hibernate: select test.S_JBPM4_TASK.nextval from dual
      
      [2009-07-22 18:05:31,062] (TaskHandler:assignTask:24) - TaskHandler
      
      Hibernate: select historypro0_.DBID_ as DBID1_4_0_, historypro0_.DBVERSION_ as DBVERSION2_4_0_, historypro0_.ID_ as ID3_4_0_, historypro0_.PROCDEFID_ as PROCDEFID4_4_0_, historypro0_.KEY_ as KEY5_4_0_, historypro0_.START_ as START6_4_0_, historypro0_.END_ as END7_4_0_, historypro0_.DURATION_ as DURATION8_4_0_, historypro0_.STATE_ as STATE9_4_0_, historypro0_.ENDACTIVITY_ as ENDACTI10_4_0_, historypro0_.NEXTIDX_ as NEXTIDX11_4_0_ from test.JBPM4_HIST_PROCINST historypro0_ where historypro0_.DBID_=?
      
      Hibernate: select test.S_JBPM4_HIST_ACTINST.nextval from dual
      
      Hibernate: insert into test.JBPM4_HIST_PROCINST (DBVERSION_, ID_, PROCDEFID_, KEY_, START_, END_, DURATION_, STATE_, ENDACTIVITY_, NEXTIDX_, DBID_) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
      
      Hibernate: insert into test.JBPM4_TASK (DBVERSION_, NAME_, DESCR_, STATE_, SUSPHISTSTATE_, ASSIGNEE_, FORM_, PRIORITY_, CREATE_, DUEDATE_, PROGRESS_, SIGNALLING_, EXECUTION_ID_, ACTIVITY_NAME_, HASVARS_, SUPERTASK_, EXECUTION_, PROCINST_, SWIMLANE_, TASKDEFNAME_, CLASS_, DBID_) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'T', ?)
      
      Hibernate: insert into test.JBPM4_HIST_ACTINST (DBVERSION_, HPROCI_, TYPE_, EXECUTION_, ACTIVITY_NAME_, START_, END_, DURATION_, TRANSITION_, NEXTIDX_, HTASK_, CLASS_, DBID_) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'task', ?)


      From the above logs, its obvious that a row is being inserted into JBPM4_HIST_ACTINST instead of JBPM4_HIST_TASK, there by causing parent key not found. Tried changing hbm's a bit by adding ignore=false, etc but ain't working. Any clues?

        • 1. Re: JBPM4.0 Oracle Parent Key Not Found Error
          sri r Newbie

          The more i look into it, i feel HistoryTaskImpl should have HistoryActivityInstanceImpl as a set, so that we can have hibernate mapping as inverse=true which would then prevent this error...

          • 2. Re: JBPM4.0 Oracle Parent Key Not Found Error
            Ronald van Kuijk Master

            There is a jira issue about taskhistory, can you refer in that to this discussion?

            Regarding the sequence, assigned=native should use a sequence in oracle afaik, so maybe a sequence reference is wrong in the hibernate schema?

            • 3. Re: JBPM4.0 Oracle Parent Key Not Found Error
              Ha Wa Newbie

              Did you ever find a solution to this problem?

              • 4. Re: JBPM4.0 Oracle Parent Key Not Found Error
                Shekhar Vemuri Newbie

                are you having the exact same problem? or is it similar? what generation strategy are you using? which FK is failing?

                • 5. Re: JBPM4.0 Oracle Parent Key Not Found Error
                  Ha Wa Newbie

                  I have a very similar problem, different FK but the same exact error message otherwise.

                  I'm using jBPM 4.0 CR1 with Oracle10g, running on JBoss 5.1.0GA.

                  16:27:12,090 INFO [App] Checking condition
                  16:27:12,090 INFO [App] no
                  16:27:12,106 WARNING [ProxyWarnLog] Narrowing proxy to class org.jbpm.jpdl.internal.model.JpdlExecution - this operation breaks ==
                  16:27:12,168 WARNING [JDBCExceptionReporter] SQL Error: 2291, SQLState: 23000
                  16:27:12,168 SEVERE [JDBCExceptionReporter] ORA-02291: integrity constraint (POC.FK_HAI_HPI) violated - parent key not found
                  
                  16:27:12,168 WARNING [JDBCExceptionReporter] SQL Error: 2291, SQLState: 23000
                  16:27:12,168 SEVERE [JDBCExceptionReporter] ORA-02291: integrity constraint (POC.FK_HAI_HPI) violated - parent key not found
                  
                  16:27:12,168 SEVERE [AbstractFlushingEventListener] Could not synchronize database state with session
                  org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
                   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:94)
                   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
                   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
                   at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:114)
                   at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:109)
                   at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:244)
                   at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2252)
                   at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2688)
                   at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79)
                   at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
                   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
                   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
                   at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
                   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
                   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
                   at org.jbpm.pvm.internal.tx.HibernateSessionResource.prepare(HibernateSessionResource.java:54)
                   at org.jbpm.pvm.internal.tx.StandardTransaction.commit(StandardTransaction.java:106)
                   at org.jbpm.pvm.internal.tx.StandardTransaction.complete(StandardTransaction.java:65)
                   at org.jbpm.pvm.internal.tx.StandardTransactionInterceptor.execute(StandardTransactionInterceptor.java:61)
                   at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:54)
                   at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:55)
                   at org.jbpm.pvm.internal.svc.TaskServiceImpl.completeTask(TaskServiceImpl.java:68)
                   at org.jbpm.pvm.internal.svc.TaskServiceImpl.completeTask(TaskServiceImpl.java:64)
                   at com.hwa.poc.server.App.runPOC(App.java:164)
                   at com.hwa.poc.server.PocImpl.runPOC(PocImpl.java:34)
                   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                   at java.lang.reflect.Method.invoke(Method.java:597)
                   at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:527)
                   at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:166)
                   at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:86)
                   at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
                   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
                   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                   at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
                   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
                   at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
                   at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
                   at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
                   at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
                   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                   at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
                   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
                   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
                   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
                   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                   at java.lang.Thread.run(Thread.java:619)
                  Caused by: java.sql.BatchUpdateException: ORA-02291: integrity constraint (POC.FK_HAI_HPI) violated - parent key not found
                  
                   at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:343)
                   at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10656)
                   at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
                   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
                   ... 51 more
                  


                  Here's my jpdl.xml:
                  <?xml version="1.0" encoding="UTF-8"?>
                  
                  <process name="test" xmlns="http://jbpm.org/4.0/jpdl">
                   <decision expr="#{arg}" g="228,336,61,49" name="runJava?">
                   <transition g="-4,-20" name="yes" to="java"/>
                   <transition g="-5,5" name="no" to="nojava"/>
                   </decision>
                   <decision expr="#{cond}" g="468,456,49,49" name="condition?">
                   <transition g="-11,-18" name="no" to="bad"/>
                   <transition g="-21,-3" name="yes" to="good"/>
                   </decision>
                   <task assignee="cathy" g="60,336,97,49" name="new">
                   <transition g="-24,-18" name="to runJava?" to="runJava?"/>
                   </task>
                   <task assignee="peter" g="276,216,97,49" name="nojava">
                   <transition name="to end" to="end" g="-41,-21"/>
                   </task>
                   <java class="com.hwa.poc.server.App" continue="sync" g="276,456,97,49" method="whatCond" name="java" var="cond">
                   <transition g="-40,-18" name="to condition?" to="condition?"/>
                   </java>
                   <task assignee="cathy" g="612,456,97,49" name="bad">
                   <transition g="-21,-16" name="to end" to="end"/>
                   </task>
                   <task assignee="peter" g="444,336,97,49" name="good">
                   <transition name="to end" to="end" g="-41,-21"/>
                   </task>
                   <end g="636,336,49,49" name="end"/>
                   <start g="84,216,49,49" name="start">
                   <transition g="7,-11" name="to new" to="new"/>
                   </start>
                  </process>
                  


                  And here's what's in my App:
                   public String whatCond() {
                   log.info("Checking condition");
                   tenth++;
                   if (tenth == 10) {
                   tenth = 0;
                   log.info("yes");
                   return "yes";
                   } else {
                   log.info("no");
                   return "no";
                   }
                   }
                  
                   public String runPOC(String arg) {
                   ProcessInstance processInstance = executionService.startProcessInstanceByKey("test");
                  
                   List<Task> taskList = taskService.findPersonalTasks("cathy");
                   Task task = taskList.get(0);
                   long taskDbid = task.getDbid();
                   taskService.setVariable(taskDbid, "arg", arg);
                   taskService.completeTask(taskDbid);
                  
                   processInstance = executionService.findProcessInstanceById(pid);
                   String result = processInstance.findActiveActivityNames().toArray()[0].toString();
                   log.info("Result: " + result);
                  }
                  


                  In my app, when I pass in "no" as my arg for the first decision ("runJava?"), it successfully goes to the nojava task. But when I pass in "yes" as the arg, it gives me this error. It seems to return from the Java task okay but it doesn't seem to be able to go onto the next task?

                  • 6. Re: JBPM4.0 Oracle Parent Key Not Found Error
                    Joram Barrez Master

                     

                    I'm using jBPM 4.0 CR1 with Oracle10g, running on JBoss 5.1.0GA.


                    Have you tried with 4.0GA already? Been out for a month now.


                    • 7. Re: JBPM4.0 Oracle Parent Key Not Found Error
                      Ha Wa Newbie

                       

                      "jbarrez" wrote:
                      I'm using jBPM 4.0 CR1 with Oracle10g, running on JBoss 5.1.0GA.


                      Have you tried with 4.0GA already? Been out for a month now.


                      I tried with 4.0GA and now I get this problem: http://www.jboss.org/index.html?module=bb&op=viewtopic&t=159251 so I can't even get the process going at all. Seems like that's worse than the situation I was in here...

                      • 8. Re: JBPM4.0 Oracle Parent Key Not Found Error
                        Ronald van Kuijk Master

                        But did you also start with a CLEAN database?

                        • 9. Re: JBPM4.0 Oracle Parent Key Not Found Error
                          Ha Wa Newbie

                          Yes, completely clean db. I even uninstalled everything and reinstalled a spanking new db...

                          • 11. Re: JBPM4.0 Oracle Parent Key Not Found Error
                            Ha Wa Newbie

                             

                            "jbarrez" wrote:
                            I'm using jBPM 4.0 CR1 with Oracle10g, running on JBoss 5.1.0GA.


                            Have you tried with 4.0GA already? Been out for a month now.


                            Okay, I don't see this problem anymore with 4.0GA. Thanks.