1 2 Previous Next 17 Replies Latest reply on May 23, 2007 12:13 PM by Edward Staub

    org.hibernate.TransientObjectException object references an

    Javit Gellaw Newbie

      Hello,

      I've just started using JBPM and I'm trying to create new State between 2 task-nodes.At the beginning the processDefinition look like this:
      1) start-state-->task-node1-->task-node2-->end-state
      but i would like to create a new State to Runtime when between this 2 task-nodes violation occur. So my ProcessDefinition have then a new State like this:
      2)start-state-->task-node1-->newstate-->task-node2-->end-state

      When I try to run the process, I get the following exception. Can anyone help please? My code looks like this:
      ==========================
      Node currentNode = executionContext.getNode();
      System.out.println("!!!----WhoIsCurrentNode: " + currentNode.toString());
      Transition oldTrans = currentNode.getDefaultLeavingTransition();#to next1
      Node nextNode = oldTrans.getTo();
      System.out.println("!!!---WhoIsnexttNode1: " +nextNode.toString());
      State stateNode = new State("WaitState"); //create me new stateNode
      Transition stateTrans = new Transition();
      currentNode.addLeavingTransition(oldTrans);
      oldTrans.setFrom(currentNode);
      oldTrans.setTo(stateNode);
      stateNode.addArrivingTransition(oldTrans);
      stateNode.addLeavingTransition(stateTrans);
      nextNode.addArrivingTransition(stateTrans);
      stateTrans.setFrom(stateNode);
      stateTrans.setTo(nextNode);

      When I try to run the process, I get the following exception. Can anyone help please? using server (jbpm-starters-kit-3.1.3)
      =================================
      13:19:23,593 DEBUG [CommandExecutorThread] waiting for more messages
      13:19:23,593 DEBUG [StaticNotifier] going to wait for (CMD_EXECUTOR, java.lang.O
      bject@1bdcbb2)
      13:19:23,593 DEBUG [DbPersistenceServiceFactory] creating persistence service
      13:19:23,593 DEBUG [DbPersistenceService] creating hibernate session
      13:19:23,593 DEBUG [DbPersistenceService] beginning hibernate transaction
      13:19:23,593 DEBUG [SchedulerThread] checking for timers
      13:19:23,593 DEBUG [JbpmContext] closing JbpmContext
      13:19:23,593 DEBUG [Services] closing service 'persistence': org.jbpm.persistenc
      e.db.DbPersistenceService@4e1a93
      13:19:23,593 DEBUG [DbPersistenceService] committing hibernate transaction
      13:19:23,593 DEBUG [DbPersistenceService] closing hibernate session
      13:19:23,734 INFO [STDOUT] ci.getVariable("Number "): '1'
      13:19:23,734 INFO [STDOUT] !!!----WhoIsCurrentNode: TaskNode(form)
      13:19:23,734 INFO [STDOUT] !!!----WhoIsnexttNode1: TaskNode(After-form)
      13:19:23,734 INFO [STDOUT] !!!T----WhoIsnexttNode2: State(WaitStateNode)
      13:19:23,734 INFO [STDOUT] ================================================
      13:19:23,734 INFO [STDOUT] ================================================
      13:19:23,734 DEBUG [GraphElement] event 'transition' on 'Transition(to next1)' f
      or 'Token(/)'
      13:19:23,734 DEBUG [GraphElement] event 'node-enter' on 'State(WaitStateNode)'
      for 'Token(/)'
      13:19:23,734 DEBUG [GraphElement] event 'after-signal' on 'TaskNode(form)' for 'Token(/)'
      13:19:23,734 DEBUG [TaskBean] assignmentlogs: []
      13:19:23,734 DEBUG [Services] executing default save operations
      13:19:23,734 DEBUG [HibernateSaveOperation] saving process instance
      13:19:23,734 DEBUG [SaveLogsOperation] flushing logs to logging service.
      13:19:23,750 DEBUG [CascadeSaveOperation] cascading save of 'org.jbpm.graph.exe.
      ProcessInstance@19bc401'
      13:19:23,750 INFO [[/jbpm]] WARNING: Component _id13 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 rig
      ht after creation!
      13:19:23,750 ERROR [TaskMgmtSession] org.hibernate.TransientObjectException: obj
      ect references an unsaved transient instance - save the transient instance befor
      e flushing: org.jbpm.graph.node.State
      13:19:23,750 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
      javax.faces.el.EvaluationException: Cannot get value for expression '#{homeBean.
      taskInstances}'
      at
      org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java
      :399)
      at javax.faces.component.UIData.getValue(UIData.java:779)
      at javax.faces.component.UIData.createDataModel(UIData.java:545)
      at javax.faces.component.UIData.getDataModel(UIData.java:534)
      at javax.faces.component.UIData.getRowCount(UIData.java:103)
      at org.apache.myfaces.renderkit.html.HtmlTableRendererBase.encodeInnerHt
      ml(HtmlTableRendererBase.java:124)
      at org.apache.myfaces.renderkit.html.HtmlTableRendererBase.encodeChildre
      n(HtmlTableRendererBase.java:94)



      Thank you,

        • 1. Re: org.hibernate.TransientObjectException object references
          Javit Gellaw Newbie

          Hi,

          does anybody have maybe any idea to solve this problem?

          Thank you for you responses

          • 2. Re: org.hibernate.TransientObjectException object references
            Ronald van Kuijk Master

            try saving the state before saving the rest (that is what the error says). If that succeeds , you'll probably get the next error about a transition... so try saving the transition before the state.

            and btw... dynamically changing a process? scary, can't it be modeled in in advance?
            and btw2... 6 hour between posting and re-asking? hmmm.....

            • 3. Re: org.hibernate.TransientObjectException object references
              Javit Gellaw Newbie

              Hi Roland, thank you for you response. I know its realy scary. But my problem is to stop the first "task-node" suppose i have in this task-node task variable with event action(ActionHandler.java). My variable name is number, so when the user give the number. My rule have to control if the number is greater than 4 means(number>4) If it is true==>then this task-node have to wait, else==> continue to next task-node. So that why i need to create a new state to solve this problem programmatically.
              The next Task-node can not solve this problem because task-node behave not like state whatever the user gives it dosen't wait.(so when i use state this will not continue so behave like wait-state). So it can't be modeled in advance. So that is why i want to create this State programmatically.

              Do you have maybe any other idea to solve this problem?

              Thanks for your interest

              • 4. Re: org.hibernate.TransientObjectException object references
                Ronald van Kuijk Master

                other solutions depend on what the process has to wait for....can you describe that?

                • 5. Re: org.hibernate.TransientObjectException object references
                  Edward Staub Expert

                  Why don't you model the wait-state in the process definition, and use transition decisions to decide whether to skip it or not?

                  -Ed Staub

                  • 6. Re: org.hibernate.TransientObjectException object references
                    Javit Gellaw Newbie

                    thanks agan, So what i want is.
                    ProcessDefnlition Start-->task-node1-->task-Node2-->End
                    user gives a number for this variable :this task-node1 node have this variable with action
                    Case 1.)if(number>4)
                    so task-node1 has to wait
                    AND new processDef will be load hier to signal letter this waiting process
                    Case 2.)elseif(number<4)
                    continue to task-node2

                    So in case1. This task-node has to wait until user change the value or until user signal this waiting task-node1 to continue ==> to next task it means to (task-node2). I hope you understand what i mean.

                    thanks

                    • 7. Re: org.hibernate.TransientObjectException object references
                      Edward Staub Expert

                      One more time...

                      Consider

                      Start transitions to task-node1 unconditionally

                      task-node1 transitions to wait-node (predefined in definition) if number > 4

                      task-node1 transitions to task-node2 if number < 4

                      wait-node transitions to task-node2 unconditionally

                      [I'm going a little beyond what I feel confident about, but...]
                      Adding topology (nodes and transitions) during execution is highly unusual at best, and will never work at worst - I'd always try to find other ways to do what you want first. Even if you get it to work in some particular release of JBPM, it's likely to get broken inadvertently.

                      -Ed Staub

                      • 8. Re: org.hibernate.TransientObjectException object references
                        Javit Gellaw Newbie

                        Hi Ed Staub,
                        first of all many thanks for your response. I know its complex to solve this problem. But i don't want to do that in the processDefinition, because who knows when this kind of mistake means (in which activity or task-node- which actor)occure. You know what i mean. Suppose you have many users say the first task-node with task for actor(ernie) has no misteke continue to the second task-node with task for actor(bert) has also no misteke so continue to the third task-node with task for(grover) he made a misteke means(his variable was not correct) i want immediately block this task and continue it letter. So i can't say when the mistake happens. I hope you understand what i want to do:) So if you have any idea to solve this problem i would be grateful for your information.

                        cheers

                        • 9. Re: org.hibernate.TransientObjectException object references
                          Edward Staub Expert

                          I'm not sure I understand, but it sounds like you want to conditionally call Token.signal().

                          -Ed Staub

                          • 10. Re: org.hibernate.TransientObjectException object references
                            Javit Gellaw Newbie

                            hmm, ya it's the right way but Token.signal() is not enough for my concept. By all means thanks for your response. If you became a new idea just give me sign.

                            thanks again

                            • 11. Re: org.hibernate.TransientObjectException object references
                              M K Newbie

                              Hi all,

                              I have roughly the same problem as Javit does. Just a quick question: How can I save a Transition or a State object?

                              My first try was to do it the same way like with a process instance:

                              executionContext.getJbpmContext().save(processInstance)


                              But:
                              executionContext.getJbpmContext().save(stateNode)


                              does not exist :-(
                              Many thanks in advance!
                              Regards,
                              Maurice

                              • 12. Re: org.hibernate.TransientObjectException object references
                                Ronald van Kuijk Master

                                hmmm yes, correct. Probably because updating just a statenode of a running instance is never needed (it's behaviour is in the processdefinition).

                                Updating a processdefinition at runtime also leads to issues since you update it for ALL running instances of that processdefinition. As a 'solution' you need a new processdefinition for each running instance, which leads to lots of other issues like problematic BAM/BI stuff....

                                Maybe a

                                • 13. Re: org.hibernate.TransientObjectException object references
                                  M K Newbie

                                  @ kukeltje: Thanks for your reply! Ok, the news are not good.

                                  Ok I'll try to real quick explain my scenario, maybe anyone has an idea how to solve it:
                                  I have a scenario where a process instance is to be evaluated by business rules (expressed by drools rules) after each single task instance of the process. This is realized through an ActionHandler, which is attached to each TaskNode and which fires the Drools rules. If any of the rules is not valid, then the process execution should simply stop and the user should get a message, i.e. a task saying "Please check componentX/valueY/wahetever". That is it so far.

                                  What I already tried is the following:

                                  1. Just insert a TaskInstance displaying the message and call processInstance.suspend() in the consequence of the Drools rule. The TaskInstance-part works fine but:
                                  -> Problem: It seems like processInstance.suspend() does not work if called out of an ActionHandler

                                  2. Insert a state node right after the current TaskNode. This inserted state node could also make the process instance pause process execution.
                                  -> Problem: TransientObjectException as described earlier in this thread

                                  3. My current workaround is this: Insert a TaskInstance for the message (as in try no. 1) and then just set the ASYNC attribute of the node following the "node that fires the rule" to true, so that the user, in case any of the rules fires, only sees the inserted TaskInstance in his work list at first, because the task that would be displayed if none of the rules would have fired was set to ASYNC.
                                  -> Problem with that: This does not really stop the process execution, it only requires a second click on "Home" in the task list in order to show the next "regular task" for the user.

                                  Ok, so hopefully this was understandable and hopefully someone has a hint for solving this issue.
                                  Many thanks in advance!
                                  Best regards,
                                  Maurice

                                  • 14. Re: org.hibernate.TransientObjectException object references
                                    Ronald van Kuijk Master

                                    Yes, it is understandable what you want to achieve, process wise. What I still do not understand is why you try to implement it by run-time modifying of the processdefinition.

                                    Several things:
                                    1: processinstance.suspend is to realy halt the process exectution, not for using it as a kind of waitstate
                                    2: Yes
                                    3: Correct

                                    Questions:
                                    - If you do not want the 'next' task to show up directly, when do you want it to show up and is there any trigger for it
                                    - what if the info entered for it is still not correct?
                                    - Why not just use a jsf validator on the input field that requires the entry to be > 4

                                    1 2 Previous Next