drools-ant task and java.lang.ClassCastException: org.drools.reteoo.ReteooRuleBase
------------------------------------------------------------------------------------
Key: JBRULES-1327
URL:
http://jira.jboss.com/jira/browse/JBRULES-1327
Project: JBoss Drools
Issue Type: Bug
Security Level: Public (Everyone can see)
Affects Versions: 4.0.3
Environment: Windows XP / Eclipse 3.2
Reporter: Brugger Antony
Priority: Blocker
I try to use the drools-ant task to generate a package file like this:
<target name="rules2" >
<rulebase
srcdir="../src/main/rules"
tofile="../rulePackage/bcpRules.rules"
classpathref="bcp.classpath" >
<include name="testRuleBcp.drl" />
</rulebase>
</target>
it is working.
But when I try to use it in my Java code with this code:
RuleAgent agent = RuleAgent.newRuleAgent("/ruleAgent.properties");
RuleBase ruleBase = agent.getRuleBase();
ruleAgent.properties file:
##
## RuleAgent configuration file
##
dir=./rulePackage
poll=30
name=MyBcpConfig
I have the following exception:
RuleAgent(MyBcpConfig) INFO (Thu Nov 15 16:16:20 CET 2007): Configuring with
newInstance=false, secondsToRefresh=30
RuleAgent(MyBcpConfig) INFO (Thu Nov 15 16:16:20 CET 2007): Configuring package provider :
DirectoryScanner scanning dir: .\rulePackage found 1 file(s).
java.lang.ClassCastException: org.drools.reteoo.ReteooRuleBase
at org.drools.agent.FileScanner.readPackage(FileScanner.java:109)
at org.drools.agent.FileScanner.getChangeSet(FileScanner.java:79)
at org.drools.agent.FileScanner.loadPackageChanges(FileScanner.java:57
Indeed when I look at the code:
- in the ant task org.drools.contrib.DroolsCompilerAntTask, this is a RuleBase object that
is serialized:
private void serializeRulebase(RuleBase ruleBase)
throws FileNotFoundException, IOException {
ObjectOutputStream outstream = null;
try {
FileOutputStream fout = new FileOutputStream(toFile);
outstream = new ObjectOutputStream(fout);
outstream.writeObject(ruleBase);
} finally {
if (outstream != null) {
outstream.close();
}
}
}
- in the ruleAgent class org.drools.agent.FileScanner is expecting a Package object to
deserialized at line 109:
p1_ = (Package) in.readObject();
hence the ClassCastException...
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira