[rules-users] Does not execute => builder.addPackageFromDrl(new InputStreamReader(this.getClass().getResourceAsStream(ruleFile)))
Mauricio Salatino
salaboy at gmail.com
Thu May 6 15:30:39 EDT 2010
You are using the old apis,
take a look at the docs about the 5 version to update your code.
If you are working with maven, it should work on eclipse and netbeans.
I'm a netbeans user and I got all my examples running.
2010/5/6 mikexr <mike at bigfatnuthin.com>
> Noe using drools 5.
>
> On May 6, 2010 12:08 PM, "salaboy [via Drools - Java Rules Engine]" <[hidden
> email] <http://user/SendEmail.jtp?type=node&node=782001&i=0>> wrote:
>
> 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 <[hidden email]<http://user/SendEmail.jtp?type=node&node=781968&i=0>
> > 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
> [hidden email] <http://user/SendEmail.jtp?type=node&node=781968&i=1>
>
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
>
> --
> - http://salaboy.wordpress.com
> - http://www.jbug.com.ar
> - Salatino "Salaboy" Mauricio -
>
> _______________________________________________
> rules-users mailing list
> [hidden email] <http://user/SendEmail.jtp?type=node&node=781968&i=2>
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
> ------------------------------
> View message @
> http://drools-java-rules-engine.46999.n3.nabble.com/Does-not-execute-builder-addPackageFromDrl-new-InputStreamReader-this-getClass-getResourceAsStream-r-tp781934p781968.html
> To unsubscribe from Does not execute => builder.addPackageFromDrl(new
> InputStreamReader(this.getClass().getResourceAsStream(ruleFile))), click
> here.
>
>
> ------------------------------
> View this message in context: Re: Does not execute =>
> builder.addPackageFromDrl(new
> InputStreamReader(this.getClass().getResourceAsStream(ruleFile)))<http://drools-java-rules-engine.46999.n3.nabble.com/Does-not-execute-builder-addPackageFromDrl-new-InputStreamReader-this-getClass-getResourceAsStream-r-tp781934p782001.html>
>
> Sent from the Drools - User mailing list archive<http://drools-java-rules-engine.46999.n3.nabble.com/Drools-User-f47000.html>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/cb389ed0/attachment.html
More information about the rules-users
mailing list