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

Mauricio Salatino salaboy at gmail.com
Thu May 6 15:04:36 EDT 2010


Are you using Drools 4.x for a particular reason? I suggest you to try with
5.x

On Thu, May 6, 2010 at 2:56 PM, mikexr <mike at bigfatnuthin.com> wrote:

>
> 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.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
- http://salaboy.wordpress.com
- http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100506/fbf7009c/attachment.html 


More information about the rules-users mailing list