4 Replies Latest reply on Feb 22, 2006 4:56 AM by mennen

    jbpm 3.1: persistence problem?

    mennen

      Hi,

      I have been trying to change a swimlane dynamically and when i'm done, i'm saving both the task instance to which to swimlane would be attached, as well as the process instance.

      But i keep getting the following error:

      ERROR [TaskMgmtSession] org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: org.jbpm.taskmgmt.exe.SwimlaneInstance


      I can't figure out what's missing, because when i print out the taskInstance's actorId, I get the right value..

      here is the error i get:

      [exec] 17:09:12,675 DEBUG [Services] executing default save operations
       [exec] 17:09:12,675 DEBUG [HibernateSaveOperation] saving process instance
       [exec] 17:09:12,675 DEBUG [SaveLogsOperation] flushing logs to logging service.
       [exec] 17:09:12,675 DEBUG [CascadeSaveOperation] cascading save of 'org.jbpm.graph.exe.ProcessInstance@1e1fcd7'
       [exec] 17:09:12,675 DEBUG [GraphElement] event 'after-signal' on 'TaskNode(task1)' for 'Token(/)'
       [exec] 17:09:12,675 DEBUG [TaskBean] assignmentlogs: []
       [exec] 17:09:12,675 DEBUG [Services] executing default save operations
       [exec] 17:09:12,675 DEBUG [HibernateSaveOperation] saving process instance
       [exec] 17:09:12,675 DEBUG [SaveLogsOperation] flushing logs to logging service.
       [exec] 17:09:12,675 INFO [STDOUT] Hibernate: insert into JBPM_LOG (INDEX_, DATE_, TOKEN_, PARENT_, TASKINSTANCE_, TASKACTORID_, CLASS_) values (?, ?, ?, ?, ?, ?, '1')
       [exec] 17:09:12,675 DEBUG [CascadeSaveOperation] cascading save of 'org.jbpm.graph.exe.ProcessInstance@1e1fcd7'
       [exec] 17:09:12,685 INFO [[/jbpm]] WARNING: Component _id19 just got an automatic id, because there was no id assigned yet. If this component was created dynamically (i.e. not by a JSP tag) you should assign it an explicit static id or assign it the id you get from the createUniqueId from the current UIViewRoot component right after creation!
       [exec] 17:09:12,685 INFO [STDOUT] Hibernate: insert into JBPM_TOKENVARIABLEMAP (TOKEN_, CONTEXTINSTANCE_) values (?, ?)
       [exec] 17:09:12,685 ERROR [TaskMgmtSession] org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: org.jbpm.taskmgmt.exe.SwimlaneInstance [exec] 17:09:12,695 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
       [exec] javax.faces.el.EvaluationException: Cannot get value for expression '#{homeBean.taskInstances}'
       [exec] at org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:399)
       [exec] at javax.faces.component.UIData.getValue(UIData.java:779)




      Here is part of my process definition:
      <task-node name="task3">
      
       <task>
       <event type="task-create">
       <action class="org.jbpm.mennen.CommandeAction2"/> </event>
       <controller>
       <variable name="Date_demande" access="read"/>
       <variable name="transition" access="read"/>
       </controller>
      
       </task>
       <transition name="" to="task4"></transition>
       </task-node>


      Here is my action CommandeAction2:

      ProcessInstance pi = executionContext.getProcessInstance();
      
      
      Swimlane swimlane =(Swimlane) executionContext.getVariable("swimlane2");
      SwimlaneInstance swimlaneInstance = new SwimlaneInstance(swimlane);
      
      executionContext.getTaskInstance().setSwimlaneInstance(swimlaneInstance);
       executionContext.getTaskInstance().getSwimlaneInstance().setActorId("luc");
      executionContext.getJbpmContext().save( executionContext.getTaskInstance());
      executionContext.getJbpmContext().save(pi);
      



      I searched on the forum for similar problems on the forum but it didn't help out..

      Thanks in advance,


        • 1. Re: jbpm 3.1: persistence problem?
          mennen

          here is a more complete error thread:

          [exec] 17:41:52,413 ERROR [Services] problem closing service 'persistence'
           [exec] org.jbpm.persistence.JbpmPersistenceException: couldn't commit hibernate session
           [exec] at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:171)
           [exec] at org.jbpm.svc.Services.close(Services.java:211)
           [exec] at org.jbpm.JbpmContext.close(JbpmContext.java:138)
           [exec] at org.jbpm.web.JbpmContextFilter.doFilter(JbpmContextFilter.java:85)
           [exec] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
           [exec] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
           [exec] at org.jbpm.webapp.filter.LogFilter.doFilter(LogFilter.java:59)
           [exec] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
           [exec] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
           [exec] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
           [exec] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
           [exec] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
           [exec] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
           [exec] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
           [exec] at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
           [exec] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
           [exec] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
           [exec] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
           [exec] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
           [exec] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
           [exec] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
           [exec] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
           [exec] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
           [exec] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
           [exec] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
           [exec] at java.lang.Thread.run(Thread.java:534)
           [exec] Caused by: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: org.jbpm.taskmgmt.exe.SwimlaneInstance
           [exec] at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:216)
           [exec] at org.hibernate.type.EntityType.getIdentifier(EntityType.java:108)
           [exec] at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:221)
           [exec] at org.hibernate.type.TypeFactory.findDirty(TypeFactory.java:476)
           [exec] at org.hibernate.persister.entity.AbstractEntityPersister.findDirty(AbstractEntityPersister.java:2802)
           [exec] at org.hibernate.event.def.DefaultFlushEntityEventListener.dirtyCheck(DefaultFlushEntityEventListener.java:457)
           [exec] at org.hibernate.event.def.DefaultFlushEntityEventListener.isUpdateNecessary(DefaultFlushEntityEventListener.java:180)
           [exec] at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:104)
           [exec] at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:195)
           [exec] at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
           [exec] at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
           [exec] at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:905)
           [exec] at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:345)
           [exec] at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
           [exec] at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:161)
           [exec] ... 25 more
           [exec] 17:41:52,413 DEBUG [Services] closing service 'logging': org.jbpm.logging.db.DbLoggingService@6081dc
           [exec] 17:41:52,413 DEBUG [Services] closing service 'authentication': org.jbpm.security.authentication.DefaultAuthenticationService@1ed9cf7
           [exec] 17:41:52,413 ERROR [[FacesServlet]] Servlet.service() for servlet FacesServlet threw exception
           [exec] org.jbpm.JbpmException: problem closing services {persistence=org.jbpm.persistence.JbpmPersistenceException: couldn't commit hibernate session}
           [exec] at org.jbpm.svc.Services.close(Services.java:223)
           [exec] at org.jbpm.JbpmContext.close(JbpmContext.java:138)
           [exec] at org.jbpm.web.JbpmContextFilter.doFilter(JbpmContextFilter.java:85)
           [exec] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
           [exec] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
           [exec] at org.jbpm.webapp.filter.LogFilter.doFilter(LogFilter.java:59)
           [exec] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
           [exec] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
           [exec] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
           [exec] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
           [exec] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
           [exec] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
           [exec] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
           [exec] at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
           [exec] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
           [exec] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
           [exec] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
           [exec] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
           [exec] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
           [exec] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
           [exec] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
           [exec] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
           [exec] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
           [exec] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
           [exec] at java.lang.Thread.run(Thread.java:534)
           [exec] Caused by: org.jbpm.persistence.JbpmPersistenceException: couldn't commit hibernate session
           [exec] at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:171)
           [exec] at org.jbpm.svc.Services.close(Services.java:211)
           [exec] ... 24 more
           [exec] Caused by: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: org.jbpm.taskmgmt.exe.SwimlaneInstance
           [exec] at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:216)
           [exec] at org.hibernate.type.EntityType.getIdentifier(EntityType.java:108)
           [exec] at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:221)
           [exec] at org.hibernate.type.TypeFactory.findDirty(TypeFactory.java:476)
           [exec] at org.hibernate.persister.entity.AbstractEntityPersister.findDirty(AbstractEntityPersister.java:2802)
           [exec] at org.hibernate.event.def.DefaultFlushEntityEventListener.dirtyCheck(DefaultFlushEntityEventListener.java:457)
           [exec] at org.hibernate.event.def.DefaultFlushEntityEventListener.isUpdateNecessary(DefaultFlushEntityEventListener.java:180)
           [exec] at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:104)
           [exec] at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:195)
           [exec] at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
           [exec] at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
           [exec] at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:905)
           [exec] at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:345)
           [exec] at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
           [exec] at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:161)
           [exec] ... 25 more


          • 2. Re: jbpm 3.1: persistence problem?
            aguizar

            Do not create SwimlaneInstances yourself. In the first place, define your task to use a swimlane:

            <process-definition ...>
             ...
             <swimlane name="myrole" .../>
             <task-node name="task3">
             <task name="mytask" swimlane="myrole">
             ...
             </task>
             <transition name="" to="task4"></transition>
             </task-node>
             ...
            </process-definition>

            Now your task instance should have a non-null swimlane instance property. Set the new actor in that swimlane instance.

            • 3. Re: jbpm 3.1: persistence problem?
              mennen

              Thank you for your reply and help.

              I tried what you said, and added a swimlane like this:

              
              <swimlane name="demandeur1">
               <assignment expression="user(mennen)"></assignment>
               </swimlane>
              
               <swimlane name="demandeur2">
               <assignment expression="user(luc)"></assignment>
               </swimlane>
              
              <task-node name="task3">
               <task swimlane = "demandeur1">
               <event type="task-create">
               <action class="org.jbpm.mennen.CommandeAction2"/>
               </event>
               <controller>
               <variable name="Date_demande" access="read"/>
               <variable name="transition" access="read"/>
               </controller>
               </task>
               <transition name="" to="task4"></transition>
               </task-node>


              And after that, i set the swimlane instance in the CommandeAction2:
              Swimlane swimlane =(Swimlane) executionContext.getVariable("swimlane2");
               SwimlaneInstance swimlaneInstance = executionContext.getTaskMgmtInstance().getSwimlaneInstance("demandeur2");//
              //SwimlaneInstance swimlaneInstance = new SwimlaneInstance(swimlane); // this was what i did before
              executionContext.getTaskInstance().setSwimlaneInstance(swimlaneInstance);


              I set the actorId to :
              executionContext.getTaskInstance().getSwimlaneInstance().setActorId("luc");


              And then i save everything:
              executionContext.getJbpmContext().save( executionContext.getTaskInstance());
               executionContext.getJbpmContext().save(pi);


              I printed the swimlaneInstance's actorId, and it was the good one: Luc.
              But when i executed the process.. it keeps assigning the task3 to the old swimlane "demandeur1" (the one defined in the process definition).

              I don't know what i'm missing,

              Please help,


              • 4. Re: jbpm 3.1: persistence problem?
                mennen

                I found a solution!

                I had a problem with getting the swimlane instance of the task instance.. it always gave me null. I realized that it's because it hasn't been initialized yet.. Here is what i did to initialize all the swimlane instances, and it worked!

                ProcessInstance pi = executionContext.getProcessInstance();
                 ProcessDefinition pd = pi.getProcessDefinition();
                 Map swimlanes = pd.getTaskMgmtDefinition().getSwimlanes();
                 Iterator itr = swimlanes.keySet().iterator();
                 while(itr.hasNext()) {
                 Swimlane swimlane = (Swimlane)swimlanes.get(itr.next());
                 SwimlaneInstance swi = pi.getTaskMgmtInstance().getInitializedSwimlaneInstance(new ExecutionContext(pi.getRootToken()), swimlane);
                 }


                I got it from a post http://www.jboss.com/index.html?module=bb&op=viewtopic&t=70160

                So now when i do this:
                SwimlaneInstance swimlaneInstance = executionContext.getTaskMgmtInstance().getSwimlaneInstance("demandeur1");
                i don't get null anymore..

                But the weird thing is that when i do this
                SwimlaneInstance swimlaneInstance = executionContext.getTaskInstance().getSwimlaneInstance();
                i get Null!!

                I guess it's because the action is in the "task-create" event.. so the task instance is not created yet maybe..

                Please tell me if i'm wrong...