JBoss Community

Marshalling of a JBPM session

created by hansi007 in jBPM - View the full discussion

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)
...
 

Reply to this message by going to Community

Start a new discussion in jBPM at Community