Uploaded image for project: 'JBRULES'
  1. JBRULES
  2. JBRULES-2485

DROOLS-FLOW: NullPointerException when completing a Workitem with parameters after resuming the flow

    Details

    • Steps to Reproduce:
      Hide

      (test ONE starts)

      Have a simple flow: [Start] --> [Workitem] --> [End]
      Have Workitem Long / Integer parameters mapped ( e.g. <mapping type="in" from="someId" to="someId" /> )
      Register a NonCompletingWorkitemHandler
      Start the flow

      (test ONE ends)

      [ In a different @Test !!! ]

      (test TWO starts)

      ksession = JPAKnowledgeService.loadStatefulKnowledgeSession( SESSION_ID, knowledgeBase, null, env );

      // ... re-register a NonCompletingWorkitemHandler

      ksession.getWorkItemManager().completeWorkItem( WORK_ITEM_ID, null );

      (test TWO ends)

      Show
      (test ONE starts) Have a simple flow: [Start] --> [Workitem] --> [End] Have Workitem Long / Integer parameters mapped ( e.g. <mapping type="in" from="someId" to="someId" /> ) Register a NonCompletingWorkitemHandler Start the flow (test ONE ends) [ In a different @Test !!! ] (test TWO starts) ksession = JPAKnowledgeService.loadStatefulKnowledgeSession( SESSION_ID, knowledgeBase, null, env ); // ... re-register a NonCompletingWorkitemHandler ksession.getWorkItemManager().completeWorkItem( WORK_ITEM_ID, null ); (test TWO ends)
    • Estimated Difficulty:
      Medium

      Description

      When trying to complete the work item [if it has ANY parameters mapped (e.g. <mapping type="in" from="someId" to="someId" />)], internally Drools Flow is using JPA persistence module to find ( retrieve ) a work item to be completed from a WorkItemInfo table.

      Interestingly enough, if you look at the "getWorkItem" method of the "org.drools.persistence.processinstance.WorkItemInfo", it passes a NULL for a RuleBase while setting up a context:

      public WorkItem getWorkItem() {
      if ( workItem == null ) {
      try {
      ByteArrayInputStream bais = new ByteArrayInputStream( workItemByteArray );
      MarshallerReaderContext context = new MarshallerReaderContext( bais,

      null, // THIS IS a RULEBASE <<<<<<<<<<<<<

      null,
      null );
      workItem = InputMarshaller.readWorkItem( context );

      And right after that, when trying to set parameters on the work item, it uses that RuleBase in MarshallerReaderContext:

      protected Class< ? > resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
      String name = desc.getName();
      try

      { return Class.forName(name, false, this.ruleBase.getRootClassLoader()); // HERE IS WHERE THE NULL POINTER EXCEPTION OCCURS <<<<<<<<<<<<<<<<<<<<<<< since the RuleBase is NULL }

      catch (ClassNotFoundException ex)

      { return super.resolveClass( desc ); }


      }

      Again, this happens after the flow is resumed having workitem(s) with parameters [ in a different thread / execution ] after the flow was suspended... Also I did not find any framework tests for it [ separate threaded (real life) ones ]

      /Anatoly

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                salaboy21 Mauricio Salatino
                Reporter:
                Anat0ly Anatoly Polinsky
              • Votes:
                3 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: