4 Replies Latest reply on Dec 29, 2005 10:59 AM by brittm

    Using taskInstance.addComment() breaks Hibernate mappings fo

    brittm Novice

      I've observed that adding a task comment breaks jbpm3's ability to add or retrieve token comments as well as its ability to delete process instances. After adding a task comment, attempting to delete the process instance results in the following:

      java.lang.RuntimeException: couldn't delete process instance '1424'
       at org.jbpm.db.GraphSession.deleteProcessInstance(GraphSession.java:315)
       at org.jbpm.db.GraphSession.deleteProcessInstance(GraphSession.java:286)
       at org.apache.jsp.admin.instance_jsp._jspService(org.apache.jsp.admin.instance_jsp:130)
       at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
       at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
       at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
       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:81)
       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.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
       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:856)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
       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:534)
      Caused by: org.hibernate.HibernateException: null index column for collection: org.jbpm.graph.exe.Token.comments
       at org.hibernate.persister.collection.AbstractCollectionPersister.readIndex(AbstractCollectionPersister.java:618)
       at org.hibernate.collection.PersistentList.readFrom(PersistentList.java:297)
       at org.hibernate.loader.Loader.readCollectionElement(Loader.java:645)
       at org.hibernate.loader.Loader.readCollectionElements(Loader.java:355)
       at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:306)
       at org.hibernate.loader.Loader.doQuery(Loader.java:395)
       at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:210)
       at org.hibernate.loader.Loader.loadCollection(Loader.java:1400)
       at org.hibernate.loader.collection.OneToManyLoader.initialize(OneToManyLoader.java:107)
       at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:483)
       at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
       at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1412)
       at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:171)
       at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:48)
       at org.hibernate.collection.PersistentList.iterator(PersistentList.java:105)
       at org.hibernate.type.CollectionType.getElementsIterator(CollectionType.java:193)
       at org.hibernate.type.CollectionType.getElementsIterator(CollectionType.java:185)
       at org.hibernate.engine.Cascades.getAllElementsIterator(Cascades.java:939)
       at org.hibernate.engine.Cascades.access$100(Cascades.java:32)
       at org.hibernate.engine.Cascades$1.getCascadableChildrenIterator(Cascades.java:71)
       at org.hibernate.engine.Cascades.cascadeCollection(Cascades.java:858)
       at org.hibernate.engine.Cascades.cascade(Cascades.java:739)
       at org.hibernate.engine.Cascades.cascade(Cascades.java:817)
       at org.hibernate.engine.Cascades.cascade(Cascades.java:789)
       at org.hibernate.event.def.DefaultDeleteEventListener.cascadeBeforeDelete(DefaultDeleteEventListener.java:248)
       at org.hibernate.event.def.DefaultDeleteEventListener.deleteEntity(DefaultDeleteEventListener.java:201)
       at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:109)
       at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:573)
       at org.hibernate.engine.Cascades$1.cascade(Cascades.java:67)
       at org.hibernate.engine.Cascades.cascade(Cascades.java:721)
       at org.hibernate.engine.Cascades.cascade(Cascades.java:817)
       at org.hibernate.engine.Cascades.cascade(Cascades.java:789)
       at org.hibernate.event.def.DefaultDeleteEventListener.cascadeAfterDelete(DefaultDeleteEventListener.java:272)
       at org.hibernate.event.def.DefaultDeleteEventListener.deleteEntity(DefaultDeleteEventListener.java:228)
       at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:109)
       at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:565)
       at org.jbpm.db.GraphSession.deleteProcessInstance(GraphSession.java:310)
       ... 28 more


      Errors identical to this 'caused by' error are thrown when attempting to add or retreive token comments. The database record for the inserted task comment has a tokenindex_ of null. Apparently Hibernate thinks these Task comments are Token comments and isn't expecting the null tokenindex_. I'm not sure of the original intent of the relationship between Task/Token comments, so I'll leave the solution up to someone who knows better.

      Thanks,
      Britt

        • 3. Re: Using taskInstance.addComment() breaks Hibernate mapping
          sateesh kumar Newbie

          Hi,

          I got the Same Error while trying to add the Comments..The Colpete Stack Trace is listed below:


          I have created a Task added the Comments and Send it to the Reviewers
          which is Rejected by one of the Reviwer and now resending it to the same Reviwer List..

          
          ===================================
          Code :
          ===================================
          public void execute( ExecutionContext executionContext ) throws Exception{
           String[] strReviewers = null;
          
           System.out.println("TOken in Execute "+executionContext.getToken());
           /*
           UserList listReviewers = (UserList)executionContext.getVariable("agency");
           System.out.println("listReviewers "+listReviewers);
          
           if(listReviewers!=null){
           strReviewers= new String[listReviewers.getUserList().size()];
           for(int i=0;i<listReviewers.getUserList().size();i++){
           strReviewers=(String)listReviewers.getUserList().elementAt(i);
           }
           }
           */
           strReviewers = (String[])executionContext.getVariable("agencyReviewers");
           String comments =(String)executionContext.getVariable("comments");
           String assigner = (String) executionContext.getVariable("assigner");
           System.out.println("strReviewers "+strReviewers);
           Token token = executionContext.getToken();
           createTasks(token,strReviewers,comments,assigner);
          
           }
           private void createTasks(Token token,String[] strReviewers,String comments,String assigner) {
           System.out.println(" Node Name :"+token.getNode().getName());
           ProcessDefinition processDefinition = token.getProcessInstance().getProcessDefinition();
           System.out.println("Process Definition :"+processDefinition);
           TaskMgmtDefinition tmd = (TaskMgmtDefinition) processDefinition.getDefinition(TaskMgmtDefinition.class);
           Task task = tmd.getTask("Review Draft");
           TaskInstance taskInstance = null;
           TaskMgmtInstance tmi = token.getProcessInstance().getTaskMgmtInstance();
           if(strReviewers!=null){
           for(int i=0;i<strReviewers.length;i++){
           taskInstance = tmi.createTaskInstance(task, token);
           taskInstance.setActorId(strReviewers);
           System.out.println("Created the Task "+ task.getName()+"for User :"+strReviewers);
           taskInstance.addComment(comments);
           taskInstance.getToken().getProcessInstance().getContextInstance().setVariable("Creator",assigner,token);
           }
           }
           else{
           System.out.println("No Reviewers are Selected !!!");
           }
           }
          
           ===================================
           Exception:
           ===================================
          
           javax.faces.FacesException: Error calling action method of component with id helloForm:commandButtonReviewerSubmit
           at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:74)
           at javax.faces.component.UICommand.broadcast(UICommand.java:106)
           at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:90)
           at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:164)
           at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:316)
           at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:106)
           at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:214)
           at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:120)
           at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:272)
           at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
           at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
           at org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)
           at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
           at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3020)
           at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
           at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
           at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:1925)
           at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1848)
           at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1288)
           at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
           at weblogic.work.ExecuteThread.run(ExecuteThread.java:179)
           Caused by: javax.faces.el.EvaluationException: Exception while invoking expression #{testXMLBean.commandButtonReviewerSubmit_action}
           at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:153)
           at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
           ... 21 more
           Caused by: org.jbpm.graph.def.DelegationException
           at org.jbpm.graph.def.GraphElement.raiseException(GraphElement.java:299)
           at org.jbpm.graph.def.GraphElement.raiseException(GraphElement.java:293)
           at org.jbpm.graph.def.GraphElement.executeActions(GraphElement.java:195)
           at org.jbpm.graph.def.GraphElement.fireAndPropagateEvent(GraphElement.java:149)
           at org.jbpm.graph.def.GraphElement.fireEvent(GraphElement.java:133)
           at org.jbpm.graph.def.Node.enter(Node.java:274)
           at org.jbpm.graph.def.Transition.take(Transition.java:92)
           at org.jbpm.graph.def.Node.leave(Node.java:349)
           at org.jbpm.graph.node.TaskNode.leave(TaskNode.java:167)
           at org.jbpm.graph.exe.Token.signal(Token.java:127)
           at org.jbpm.graph.exe.Token.signal(Token.java:92)
           at test.TestXMLBean.commandButtonReviewerSubmit_action(TestXMLBean.java:450)
           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:585)
           at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129)
           ... 22 more
           Caused by: org.hibernate.HibernateException: null index column for collection: org.jbpm.graph.exe.Token.comments
           at org.hibernate.persister.collection.AbstractCollectionPersister.readIndex(AbstractCollectionPersister.java:618)
           at org.hibernate.collection.PersistentList.readFrom(PersistentList.java:298)
           at org.hibernate.loader.Loader.readCollectionElement(Loader.java:674)
           at org.hibernate.loader.Loader.readCollectionElements(Loader.java:370)
           at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:314)
           at org.hibernate.loader.Loader.doQuery(Loader.java:412)
           at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
           at org.hibernate.loader.Loader.loadCollection(Loader.java:1434)
           at org.hibernate.loader.collection.OneToManyLoader.initialize(OneToManyLoader.java:111)
           at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:488)
           at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
           at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1430)
           at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:176)
           at org.hibernate.collection.AbstractPersistentCollection.write(AbstractPersistentCollection.java:61)
           at org.hibernate.collection.PersistentList.add(PersistentList.java:131)
           at org.jbpm.graph.exe.Token.addComment(Token.java:199)
           at org.jbpm.taskmgmt.exe.TaskInstance.addComment(TaskInstance.java:361)
           at gov.archives.era.workflow.createDispositionAgreement.CreateTasks.createTasks(CreateTasks.java:53)
           at gov.archives.era.workflow.createDispositionAgreement.CreateTasks.execute(CreateTasks.java:37)
           at org.jbpm.graph.def.Action.execute(Action.java:79)
           at org.jbpm.graph.def.GraphElement.executeActions(GraphElement.java:186)
           ... 36 more
          



          Thanks
          Sateesh