[jboss-jira] [JBoss JIRA] (DROOLS-778) Deserialization error: java.io.InvalidClassException: org.drools.base.evaluators.StrEvaluatorDefinition$StrEvaluator; no valid constructor
Christoph Schachinger (JIRA)
issues at jboss.org
Tue Sep 20 09:04:00 EDT 2016
[ https://issues.jboss.org/browse/DROOLS-778?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13295694#comment-13295694 ]
Christoph Schachinger commented on DROOLS-778:
----------------------------------------------
The issue is back with 6.4.0. We are serialising the knowledge-packages and deserializing them (for a quicker startup). This stars breaking with 6.4 for thouse rules which have the "str" operation in their WHEN condition.
> Deserialization error: java.io.InvalidClassException: org.drools.base.evaluators.StrEvaluatorDefinition$StrEvaluator; no valid constructor
> -------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: DROOLS-778
> URL: https://issues.jboss.org/browse/DROOLS-778
> Project: Drools
> Issue Type: Bug
> Components: core engine
> Affects Versions: 5.5.0.Final
> Environment: Windows 7; Java 6; Drools 5.5.0.Final (incl. drools-core, drools-compiler, drools-spring and drools-camel)
> Reporter: Philip McWilliams
> Assignee: Mario Fusco
> Fix For: 6.0.0.Final
>
>
> I am seeking to compile rules at build-time and then save (serialize) the output to disk. At deployment, I then wish to build a knowledge base from the deserialized knowledge packages (rather than by re-compiling the source rules files).
> In general this works ... unless I use the "str" operator in an LHS. This operator is implemented by the *org.drools.base.evaluators.StrEvaluatorDefinition$StrEvaluator* class and this class does not appear to deserialize properly.
> A round trip exercise on my local machine always fails with this error:
> {code}
> java.io.InvalidClassException: org.drools.base.evaluators.StrEvaluatorDefinition$StrEvaluator; org.drools.base.evaluators.StrEvaluatorDefinition$StrEvaluator; no valid constructor
> {code}
> My serialization/deserialization code is standard ... to serialize:
> {code}
> private void saveOutput(KnowledgeBuilder kbuilder) throws IOException {
> Collection<KnowledgePackage> kpkgs = kbuilder.getKnowledgePackages();
> String outputFilename = outputFile == null ? "" : outputFile.trim();
> if (outputFilename.isEmpty()) {
> outputFilename = project.getBasedir() + "target/classes/drools.drlx";
> }
> ObjectOutputStream out = null;
> try {
> getLog().info("Saving compiled Drools output to " + outputFilename);
> out = new ObjectOutputStream(new FileOutputStream(outputFilename));
> out.writeObject(kpkgs);
> } finally {
> if (out != null) {
> out.close();
> }
> }
> }
> {code}
> ... to deserialize:
> {code}
> private Collection<KnowledgePackage> deserializeKnowledgePackages(Resource[] knowledgePackageObjects) throws IOException, ClassNotFoundException {
> Collection<KnowledgePackage> knowledgePackages = new ArrayList<KnowledgePackage>();
> for (Resource knowledgePackageObject : knowledgePackageObjects) {
> LOG.info("Deserializing pre-compiled package " + knowledgePackageObject.getFilename());
> ObjectInputStream in = null;
> try {
> in = new ObjectInputStream(knowledgePackageObject.getInputStream());
> // The input stream might contain an individual package or a collection.
> knowledgePackages.addAll((Collection<KnowledgePackage>) in.readObject());
> } finally {
> if (in != null) {
> in.close();
> }
> }
> }
> return knowledgePackages;
> }
> {code}
> My workaround is to avoid using the "str" operator.
> *Apologies*: I have *not* checked version 6.2.0.Final because I have not yet worked out what versions of the Drools Spring and Camel modules to use (for 5.5.0.Final they were all versioned identically).
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
More information about the jboss-jira
mailing list