[rules-users] Serialization in Drools 5.0 M2

Michal Bali michalbali at gmail.com
Tue Nov 4 05:10:33 EST 2008


Hi Siddhartha,
See this blog for more info:
http://blog.athico.com/2008/05/efficient-binary-protocol-marshalling.html
"The DefaultMarshalling
<http://fisheye.jboss.org/browse/JBossRules/trunk/drools-core/src/main/java/org/drools/marshalling/DefaultMarshaller.java?r=HEAD>class
uses the Identity strategy if it is not passed a strategy factory."
Identity strategy is stateful. This means that the same instance needs to be
used for deserialization.
You may try the Serialised strategy -
SerializablePlaceholderResolverStrategy. However, with this strategy the
fact identities change when you deserialize. That may or may not be a
problem, depending on what you are doing.
Best Regards,
Michal

On Mon, Nov 3, 2008 at 9:06 PM, siddhartha banik <siddhartha.banik at gmail.com
> wrote:

> Hi Drools Team,
>
> I am trying out new Serialization technique introduced in Drools 5.0 using
> "org.drools.marshalling.DefaultMarshaller".
>
> The use case I am trying, is:
>                                       Create a Stateful session.
>                                       Then Serialize that.
>                                       Try to load the the serialized
> session back.
>
> Loading of serialized session is working good if, I try that in same java
> program & same object of DefaultMarshaller is used during serialization & de
> serialization of the Stateful session.
>
> But, when I tried a different instance of DefaultMarshaller to read back
> the saved session, that is not working anymore. I am getting a exception :
>
> java.lang.NullPointerException
>  at org.drools.common.DefaultFactHandle.<init>(DefaultFactHandle.java:78)
>
>  at
> org.drools.marshalling.InputMarshaller.readFactHandle(InputMarshaller.java:331)
>  at
> org.drools.marshalling.InputMarshaller.readFactHandles(InputMarshaller.java:277)
>  at
> org.drools.marshalling.InputMarshaller.readSession(InputMarshaller.java:179)
>  at
> org.drools.marshalling.DefaultMarshaller.read(DefaultMarshaller.java:58)
>  at
> org.drools.marshalling.DefaultMarshaller.read(DefaultMarshaller.java:15)
>  at
> org.drools.reteoo.ReteooRuleBase.readStatefulSession(ReteooRuleBase.java:277)
>  at
> org.drools.common.AbstractRuleBase.readStatefulSession(AbstractRuleBase.java:321)
>  at
> com.sample.test.NewMarshallingTest.testSerializationInFile_1(NewMarshallingTest.java:79)
>  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>  at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>  at java.lang.reflect.Method.invoke(Unknown Source)
>  at junit.framework.TestCase.runTest(TestCase.java:154)
>  at junit.framework.TestCase.runBare(TestCase.java:127)
>  at junit.framework.TestResult$1.protect(TestResult.java:106)
>  at junit.framework.TestResult.runProtected(TestResult.java:124)
>  at junit.framework.TestResult.run(TestResult.java:109)
>  at junit.framework.TestCase.run(TestCase.java:118)
>  at
> org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
>  at
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>  at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
>  at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
>  at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
>  at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
>
> With Drools 4.0.7 ... I can serialize a Stateful session & at later point
> of time I can deserialize that back. For our usecase, the feature is very
> critical.
>
> Does Drools 5.0 support that ?  DefaultMarshaller is not serializable. So
> once a  Stateful session is serialized. At Later point of time, I am not
> able to read that back.
>
> I have attached my test files.
>
>
> Best Regards!
> Siddhartha
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20081104/07ef2964/attachment.html 


More information about the rules-users mailing list