[jboss-jira] [JBoss JIRA] Closed: (JBRULES-1327) drools-ant task and java.lang.ClassCastException: org.drools.reteoo.ReteooRuleBase

Fernando Meyer (JIRA) jira-events at lists.jboss.org
Thu Mar 13 16:40:58 EDT 2008


     [ http://jira.jboss.com/jira/browse/JBRULES-1327?page=all ]

Fernando Meyer closed JBRULES-1327.
-----------------------------------

    Fix Version/s: 4.0.5
                   5.0.0-M1
       Resolution: Done

Done!

Now you can declare a compiler task and use the binfromat parameter containing "package" for a serialized package or the default "rulebase"

	<target name="dslRules" >
		<compiler 
			srcdir="${eclipsepath}src/test/resources/rules" 		
			tofile="${eclipsepath}target/cheese.rules.dpkg"
			classpathref="cheese.classpath" 
			binformat="package" > 
			<include name="*.dslr" />
		</compiler>
	</target>


> 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
>         Assigned To: Fernando Meyer
>            Priority: Minor
>             Fix For: 4.0.5, 5.0.0-M1
>
>
> 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

        



More information about the jboss-jira mailing list