1 Reply Latest reply on May 14, 2012 10:44 AM by Mauricio Salatino

    Marshalling of a JBPM session

    hansi007 Newbie

      I want to marshall my jbpm session. Therefore i used the tutorial http://packtlib.packtpub.com/library/9781849511964/ch02lvl1sec02

      My code to marshall:

      KnowledgeBase kbase = ...
      StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null, env );
      ...
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
                          Marshaller marshaller = MarshallerFactory.newMarshaller(kbase);
                          File file = new File("ksession_"+sessionId+".info");
                          FileOutputStream foStream;
                          try {
                                    foStream = new FileOutputStream(file);
                                    marshaller.marshall(baos, ksession);
                                    baos.writeTo(foStream);
                                    baos.close();
                          } catch (FileNotFoundException e) {
                                    e.printStackTrace();
                          } catch (IOException e) {
                                    e.printStackTrace();
                          }
      

       

      If this code is executed the following exception occurs (in the line "marshaller.marshall(baos, ksession);"):

       

      java.lang.ClassCastException: org.drools.command.impl.CommandBasedStatefulKnowledgeSession cannot be cast to org.drools.impl.StatefulKnowledgeSessionImpl
                at org.drools.marshalling.impl.DefaultMarshaller.marshall(DefaultMarshaller.java:134)
                at org.drools.marshalling.impl.DefaultMarshaller.marshall(DefaultMarshaller.java:126)
      ...
      
      
        • 1. Re: Marshalling of a JBPM session
          Mauricio Salatino Master

          You are already using a persistent session that uses JPA to persist its status, why do you wan to marshal that session?

          The default marshallers work with StatefulKnowledgeSessionImpl and the JPAKnowledgeService creates a CommandBasedStatefulSession. So the question is, do you want to serialize to disk or to the DB?

          Cheers