1 2 Previous Next 20 Replies Latest reply on Aug 12, 2006 11:06 AM by Ronald van Kuijk

    Error in node-->TaskNode

    wu harder Newbie

      ProcessDefinition:

      <start-state name="a">
       <transition name="tra to="b">
       </transition>
       </start-state>
       <task-node name="b">
       <task name="first">
       <assignment class="com.test.assignment.PartMaster" config-type="bean">
       <groupName>leader</groupName>
       </assignment>
       </task>
       <transition name="tra2" to="c">
       </transition>
       </task-node>

      i can get the transition object of "tra",but error is in "node"-->"tasknode":
      TaskNode node = (TaskNode) transition.getTo();

      why??
      thanks!



        • 1. Re: Error in node-->TaskNode
          Konstantin Kolev Newbie

          Hi!
          I don't know if this is because of the forum formating the postings or you personally misspelled it but it seems you miss one double quote after name="tra.

          Regards

          • 2. Re: Error in node-->TaskNode
            wu harder Newbie

            sorry!
            that is misspelled!!
            ProcessDefinition:

            <start-state name="a">
             <transition name="tra" to="b">
             </transition>
             </start-state>
             <task-node name="b">
             <task name="first">
             <assignment class="com.test.assignment.PartMaster" config-type="bean">
             <groupName>leader</groupName>
             </assignment>
             </task>
             <transition name="tra2" to="c">
             </transition>
             </task-node>
            
            

            first,I can get a object of transition that name is "tra",
            but there is an error when i get the object of tasknode by the transition.getTo()
            TaskNode tasknode = (TaskNode) transition.getTo();

            there is not the error if i get the object of node by by the transition.getTo()
            Node node = (Node) transition.getTo();

            i know the node is the father class of the tasknode, i had seen the code in the exmaple of org.jbpm.test:
            public void testTaskNode() {
            ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
            "<process-definition>" +
            " <task-node name='t' signal='first-wait' create-tasks='false'>" +
            " " +
            " " +
            " " +
            " " +
            " " +
            " </task-node>" +
            "</process-definition>"
            );

            processDefinition = saveAndReload(processDefinition);

            TaskNode taskNode = (TaskNode) processDefinition.getNode("t");
            }




            • 3. Re: Error in node-->TaskNode
              Chris OBrien Novice

              Pasting the error would help

              • 4. Re: Error in node-->TaskNode
                wu harder Newbie

                again!
                that is misspelled!!
                ProcessDefinition:

                <start-state name="a">
                 <transition name="tra" to="b">
                 </transition>
                 </start-state>
                 <task-node name="b">
                 <task name="first">
                 <assignment class="com.test.assignment.PartMaster" config-type="bean">
                 <groupName>leader</groupName>
                 </assignment>
                 </task>
                 <transition name="tra2" to="c">
                 </transition>
                 </task-node>




                first,I can get a object of transition that name is "tra",
                but there is an error when i get the object of tasknode by the transition.getTo()

                TaskNode tasknode = (TaskNode) transition.getTo();


                there is not the error if i get the object of node by by the transition.getTo()
                Node node = (Node) transition.getTo();


                i know the node is the father class of the tasknode, i had seen the code in the exmaple of org.jbpm.test:

                public void testTaskNode() {
                ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
                 "<process-definition>" +
                 " <task-node name='t' signal='first-wait' create-tasks='false'>" +
                 " <task name='change the world once' blocking='true'>" +
                 " <assignment class='anyonebutme' />" +
                 " </task>" +
                 " <task name='change the world twice' />" +
                 " <task name='change the world three times' />" +
                 " </task-node>" +
                 "</process-definition>"
                );
                
                processDefinition = saveAndReload(processDefinition);
                
                TaskNode taskNode = ( TaskNode ) processDefinition. getNode("t");
                }





                • 5. Re: Error in node-->TaskNode
                  Chris OBrien Novice

                  What error?

                  "cpob" wrote:
                  Pasting the error would help


                  • 6. Re: Error in node-->TaskNode
                    wu harder Newbie

                    thanks,i have find the causation of the error!

                    public class Transition extends GraphElement {
                    ......
                    public Node getTo() {
                     return to;
                     }
                    ......
                    }


                    public class ProcessDefinition extends GraphElement implements NodeCollection {
                     public Node getNode(String name) {
                     if (nodes==null) return null;
                     return (Node) getNodesMap().get(name);
                     }
                    }


                    the define is different between Transition.getTo() and ProcessDefinition.getNode().


                    • 7. Re: Error in node-->TaskNode
                      Chris OBrien Novice

                      I really can't follow what the problem is without you showing us the error you are getting along with the stack trace..

                      • 8. Re: Error in node-->TaskNode
                        wu harder Newbie

                        sorry!
                        Imy english is poor! so i can't make clear by explanation what i want to say! i would Learn English more!
                        thanks

                        • 9. Re: Error in node-->TaskNode
                          Ronald van Kuijk Master

                          That is no problem, but I assume your understand java and that errors are in most cases displayed in stacktraces. Posting that would realy help us helping you

                          • 10. Re: Error in node-->TaskNode
                            wu harder Newbie

                            you are right,kukeltje,i am a rookie of java,i can do a application of web of jbpm.
                            today,i debug the application in the eclipse,get the error of ClassCastException in the code:

                            TaskNode tasknode = (TaskNode) transition.getTo();


                            can you help me, thanks

                            • 11. Re: Error in node-->TaskNode
                              wu harder Newbie

                              oh,i develope in eclipse + tomcat5.5+mysql,
                              so there no massage in console of tomcat,i can only get error of the exception by debugging in the eclipse.

                              • 12. Re: Error in node-->TaskNode
                                Ronald van Kuijk Master

                                I already figured out you were a rookie in Java since the term 'stacktrace' does not mean anything to you. Besides that, for good support it is common to post the code you use. And why do you only get the error when debugging eclipse.

                                You have to provide us LOTS more information to be able to help you

                                • 13. Re: Error in node-->TaskNode
                                  wu harder Newbie

                                  thanks,kukeltje
                                  i want to get the next tasknode("b") by transition of the current node "a",
                                  the ProcessDefinition:

                                  <start-state name="a">
                                   <transition name="tra to="b">
                                   </transition>
                                   </start-state>
                                   <task-node name="b">
                                   <task name="first">
                                   <assignment class="com.test.assignment.PartMaster" config-type="bean">
                                   <groupName>leader</groupName>
                                   </assignment>
                                   </task>
                                   <transition name="tra2" to="c">
                                   </transition>
                                  </task-node>

                                  my code :
                                  .....
                                  (transition is the object of the "tra")
                                  Node node=transition.getTo();
                                  TaskNode tasknode = (TaskNode) node;
                                  Task tptask = tasknode.getTask("first");
                                   PartMaster parma = (PartMaster) tptask.getAssignmentDelegation()
                                   .getInstance();
                                  String tpstr = parma.getGroupName();

                                  my goal is that i can get "leader" from the ProcessDefinition!but "ClassCastException" is Thrown in the second line,the description of ClassCastException:
                                  /**
                                   * Thrown to indicate that the code has attempted to cast an object
                                   * to a subclass of which it is not an instance. For example, the
                                   * following code generates a <code>ClassCastException</code>:
                                   * <p><blockquote><pre>
                                   * Object x = new Integer(0);
                                   * System.out.println((String)x);
                                   * </pre></blockquote>
                                   *
                                   * @author unascribed
                                   * @version 1.20, 12/19/03
                                   * @since JDK1.0
                                   */
                                  do you understand my description?thanks

                                  • 14. Re: Error in node-->TaskNode
                                    Ronald van Kuijk Master

                                    I partly understand. You want to know the actor of the next Task right? Besides lots of other issues with that (e.g. the assignmenthandler might not have gone off so it is impossible to know.)

                                    Again you did not provide enough information, stripped out code (how do you get the transition object, what is the value of it etc..) and regarding what you post about the classcastexception I honestly advice you to take a Java course first (assuming you are not playing a joke on me). But... I'm not a bad guy ans will try to simulate the error you get (not that I can provide a solution, see my first remark)

                                    1 2 Previous Next