byte[] serializedSession = null;
serializedRulebase = null;
baos = new ByteArrayOutputStream();
ksession = new StatefulKnowledgeSessionImpl( (ReteooStatefulSession ) session );
marshaller = MarshallerFactory.newMarshaller( ksession.getKnowledgeBase() );
marshaller.marshall( baos, ksession );
baos.close();
serializedRulebase = DroolsStreamUtils.streamOut( ruleBase );
session.dispose();
// Deserialize the rulebase and the session