Uploaded image for project: 'JBRULES'
  1. JBRULES
  2. JBRULES-1327

drools-ant task and java.lang.ClassCastException: org.drools.reteoo.ReteooRuleBase

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Done
    • Affects Version/s: 4.0.3
    • Fix Version/s: 4.0.5, 5.0.0.M1
    • Component/s: None
    • Labels:
      None
    • Environment:

      Windows XP / Eclipse 3.2

      Description

      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:
      ##

        1. 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

        Unknown macro: { 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...

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                fmeyer Fernando Meyer
                Reporter:
                abrugger Brugger Antony
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: