5 Replies Latest reply on Oct 7, 2011 9:05 AM by swiderski.maciej

    Problem with insertion of process instance into a knowledge session

    mnorsic

      Hi all,

       

      I have a small test process that uses persistency to store process and knowledge session data into a database.As part of my process workflow I have a Rule Task that pulls WorkflowProcessInstance from a knowledge session, and therefore I have to insert process instance into a ksession, as shown on picture:

       

      sample.png

       

       

      Upon signalEvent(), process continues, calls rule task and runs to completion, and there is nothing wrong with that.

       

      The problem is that my rule does not run:

       

      rule "Test WorkflowProcessInstance existence" ruleflow-group "test"
          when
              $p : WorkflowProcessInstance()
          then
              System.out.println("Process instance exists!");
      end
      

       

      It is obvious that I'm missing WorkflowProcessInstance in a knowledge session, and therefore I've added it.

      But now I'm getting the following exception upon calling UserTransaction.commit() method:

      java.io.NotSerializableException: org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl$1
       at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164)
       at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
      ...
      

       

      It seems to me it is a bug in jBPM5.1, could someone please check it?

      If this is a bug, I can create a Jira issue, but since I'm a jBPM greenhorn, I'd rather like to check on forum first because maybe I'm missing something obvious

       

      I'm attaching a sample Eclipse project with both persistent and non-persistent scenario.

       

      Thanks,

      Miljenko

        • 1. Re: Problem with insertion of process instance into a knowledge session
          mnorsic

          Hi,

           

          I've opened a JIRA issue: https://issues.jboss.org/browse/JBPM-3379

           

          Thanks,

          Miljenko

          • 2. Re: Problem with insertion of process instance into a knowledge session
            mnorsic

            Hi,

             

            a little more digging shows that if I alter process definition and remove Signal Event and converge gateway, everything works OK!??

             

            I don't get it: this should always work regardless of the process elements, and it seems that in this particular scenario it does not work.

             

            Also, I see that I did not load DRL file, but this is irrelevant (you can alter method readKnowledgeBase() and add sample.drl into a knowledge builder).

            I have tried to use Janino compiler, set JPA placeholder resolver transaction strategy (according to Variable Persistence Strategy, set JPAPlaceholderResolverStrategy into Environment) but that did not help.

             

            Miljenko

            • 3. Re: Problem with insertion of process instance into a knowledge session
              swiderski.maciej

              Hi Miljenko,

               

              I just look at your case and I think that it is very strange behavior. I debug it a bit and it turned out that the issue is in fact related to the signal event. It is stored under externalEventListeners map of WorkflowProcessInstanceImpl which is a super class for RuleflowProcessInstance.

              I made very quick change in that class to make this map transient - after that your process completed successfully with firing of the rule - since the process instance was found in the session.

              I made yet another test to verify if that did brake anything (as far as I could test it) so I made your process run in two steps:

              1. create process instance and dispose the session

              2. load the session, load the process instance and signal it

              all steps went fine, no exception whatsoever.

               

              So question is why that map is not serialized and should it be serialized? I thought events are kept in DB...

               

              what do you think about it?

              1 of 1 people found this helpful
              • 4. Re: Problem with insertion of process instance into a knowledge session
                mnorsic

                Hi Maciej,

                 

                thanks a lot for the effort!

                As for the events, my personal opinion is that events should be persisted with all other artefacts that comprise process.

                That is, because a process could be serialized into database in any "safe point" of its execution, and after its deserialization all connections between process elements and its listeners should be re-created.

                 

                If you open JIRA issue, you'll see that Kris had already marked it as solved, with the explanation that the signal was registering a non-serializable listener. But I don't see the solution...

                 

                Thanks,

                Miljenko

                • 5. Re: Problem with insertion of process instance into a knowledge session
                  swiderski.maciej

                  Yeah, you're right it is solved. It is already commited to github and in fact you can grab a nightly build that contains that fix from Jenkins: https://hudson.jboss.org/jenkins/job/jBPM/785/artifact/jbpm-distribution/target/

                   

                  Cheers