Has anybody an idea whats these problems? I didnt find any test cases,
are there any test cases for serializing the PKG files? What am I doing
[mailto:email@example.com] Im Auftrag von Bernd Rücker
Gesendet: Dienstag, 1. September 2009 17:26
Betreff: [rules-users] WG: Serialization of packages:
InvalidClassException / serialVersionUID
The exception of the KnowledgePackage serialization (by the way, this is
described in the docs, that you can serialize the KnowledgePackages!):
Exception in thread "main" java.io.NotSerializableException:
So this doesnt work either
3.2.4. Building and Deployment in Separate Processes
Both the KnowledgeBase and the KnowledgePackage are units of deployment
and serializable. This means you can have one machine do any necessary
building, requiring drools-compiler.jar, and have another machine deploy
and execute everything, needing only drools-core.jar.
Although serialization is standard Java, we present an example of how one
machine might write out the deployment unit and how another machine might
read in and use that deployment unit.
Example 3.15. Writing the KnowledgePackage to an OutputStream
ObjectOutputStream out = new ObjectOutputStream( new FileOutputStream(
fileName ) );
out.writeObject( kpkgs );
Example 3.16. Reading the KnowledgePackage from an InputStream
ObjectInputStream in = new ObjectInputStream( new FileInputStream(
fileName ) );
// The input stream might contain an individual
// package or a collection.
@SuppressWarnings( "unchecked" )
Collection<KnowledgePackage> kpkgs =
()in.readObject( Collection<KnowledgePackage> );
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages( kpkgs );
The KnowledgeBase is also serializable and some people may prefer to build
and then store the KnowledgeBase itself, instead of the Knowledge
Drools Guvnor, our server side management system, uses this deployment
approach. After Guvnor has compiled and published serialized Knowledge
Packages on a URL, Drools can use the URL resource type to load them.
Von: Bernd Rücker [mailto:firstname.lastname@example.org]
Gesendet: Dienstag, 1. September 2009 17:21
Betreff: Serialization of packages: InvalidClassException /
I really struggled some time with serialization issues: I want to create a
pkg and package that with the jar. >From there I want to read it during
Easy I thought. Drools 5 way should be to serialize the KnowledgeBase,
right? At least, this is what the AntTask does.
If I try to serialize the KnowledgePackage I get an excpetion anyway:
Okay. Back to the KnowledgeBase. Serialized with Drools 5.0.0.M4 and try
to read it with 5.0.0.M5:
Caused by: java.io.InvalidClassException:
local class incompatible: stream classdesc serialVersionUID =
local class serialVersionUID = -3186110098262381425
So it seems Drools Packages are NOT compatible between minor versions?
This would be a disaster for deployment. Or do I serialize the wrong
thing? Unfortunately I didnt find anything in the docs about it.
Then I tried to do it the old Drools 4 way and serialize Package
objects, but same problem with a different serialVersionUID!
Why do these important classes dont have a serialVersionUID? Or how
should that be loaded? Must be a big issue with Govner, so I think there
must be a solution already?
Thanks for any help!