[rules-users] Does not execute => builder.addPackageFromDrl(new InputStreamReader(this.getClass().getResourceAsStream(ruleFile)))

mikexr mike at bigfatnuthin.com
Thu May 6 14:56:58 EDT 2010


I am trying to execute a proof of concept.  I have some code  that runs a
rule.  It works in Eclipse, but for some reason doesnt in Netbeans.  I want
to get it working within a POJO Service Engine in Glassfish ESB and have is
execute as part of a BPEL orchestration.  It does not throw an exception,
but it steps over that one piece of code

   public void xmlImpl(String is) throws JAXBException,
FileNotFoundException, Exception {
        try {
            // unmarshal xml file

            //  JAXBElement<EnrollmentRequest> enrollment = 
jaxbUnmarshalFromInputStream(is);
            EnrollmentRequest enrollment = jaxbUnmarshalFromInputStream(is);

            // setup rules engine
            RuleRunner rule = new RuleRunner();

            String[] rules = {"../rules/834rules.drl"};
            // execute rules on xml file

            try {


                RuleBase ruleBase = RuleBaseFactory.newRuleBase();
                PackageBuilder builder = new PackageBuilder();


                for (String ruleFile : rules) {
                    System.out.println("Loading file: " + ruleFile);
                    builder.addPackageFromDrl(new
InputStreamReader(this.getClass().getResourceAsStream(ruleFile)));
                }

                Package pkg = builder.getPackage();
                ruleBase.addPackage(pkg);

                WorkingMemory workingMemory = ruleBase.newStatefulSession();
                Object fact = new Object();
                fact.equals(enrollment);
                System.out.println("Inserting fact: " + fact);
                workingMemory.insert(fact);

                System.out.println("Firing Rules");
                workingMemory.fireAllRules();

            } catch (Exception e) {
                e.printStackTrace();
            }

            // marshall changes out to xml file

            jaxbMarshalToOutputStream(enrollment, new
FileOutputStream("F:/data/workspaces/enrollmentPOC/data/xmlenrollment.xml"));

        } catch (JAXBException je) {
            je.printStackTrace();
        } catch (IOException ioe) {
            ioe.printStackTrace();
        } finally {
            try {
            } catch (Exception ex) {
               
java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.SEVERE,
null, ex);
            }
            return;
        }

    }


If anyone has any suggestions I would appreciate them.  At this point I'm
stuck

Thanks
-- 
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Does-not-execute-builder-addPackageFromDrl-new-InputStreamReader-this-getClass-getResourceAsStream-r-tp781934p781934.html
Sent from the Drools - User mailing list archive at Nabble.com.



More information about the rules-users mailing list