[rules-users] Weird error with rule files

Giovanni Motta mottagio at gmail.com
Wed Jun 16 04:19:08 EDT 2010


Hi, if you write a file in a source folder, it doesn't mean you can
immediately access it through the classLoader...Eclipse will put your
resource in the  classpath when it refreshes the project (e.g. the next time
you start the application). This is why you don't get the resource
immediately.
If you need that kind of flexibility (write and read a file on the same
Thread), you should write on a temporary dir of your project and read from
there. To do a better job, i suggest the process of creating the .drl from
the .brl should be separated (e.g. compile-time, when you build your
project, with maven or ant) . That way, you will always have access to the
.drl thtough the class loader.

Regards.

2010/6/15 Fnu Mahalakshmi <FMahalakshmi at nyx.com>

>  Hi,
>
>
>
> When I run my project – I have brl and drl rule files.
>
> When I run it for the first time: I am converting brl to drl files.
>
> I get this error
>
>
>
> Exception in thread "main" *java.lang.NullPointerException*
>
>       at java.io.Reader.<init>(Unknown Source)
>
>       at java.io.InputStreamReader.<init>(Unknown Source)
>
>       at com.org.RuleRunner.loadRuleFile(*RuleRunner.java:87*)
>
>       at com.org.RuleRunner.loadRules(*RuleRunner.java:44*)
>
>       at com.org.RuleRunner.runStatelessRules(*RuleRunner.java:108*)
>
>       at com.org.RulesTest.main(*RulesTest.java:40*)
>
>
>
>
>
> But after I run it for the first time and the rule.drl (converted file from
> brl to drl) exists in my directory – I run it again and then the program
> runs fine.
>
>
>
> So number of .brl files that many number of exceptions(same as above) and
> then program runs.
>
>
>
> Why is this happening?? Should it not create the file and load it into the
> rulebase?
>
>
>
> My code for converting from brl to drl is :
>
>        *try*{
>
>                   BRXMLPersistence read = (BRXMLPersistence)
> BRXMLPersistence.*getInstance*();
>
>                   BRDRLPersistence write = (BRDRLPersistence)
> BRDRLPersistence.*getInstance*();
>
>                   brl = FileUtils.*readFileToString*(file);
>
>                 System.*out*.println("File content: " + brl);
>
>                 outputDRL = write.marshal(read.unmarshal(brl));
>
>                 String drlFilePath = "src/main/rules"+rulesFiles +".drl";
>
>                 System.*out*.println("drlFilePath "+drlFilePath +"rulesFiles
> "+rulesFiles);
>
>                 String path = rulesFiles+".drl";
>
>                 System.*out*.println("path "+path);
>
>                 System.*out*.println("drlfile "+drlFilePath);
>
>                 drlFile = *new* File(drlFilePath);
>
>                 FileUtils.*writeStringToFile*(drlFile, outputDRL);
>
>
>
>                 Reader source = *new* InputStreamReader( RuleRunner.*class
> *.getResourceAsStream(path) ); // error is here
>
>                 addRulesToThisPackage.addPackageFromDrl(source);
>
>             }*catch* (IOException e) {
>
>
>
>                   e.printStackTrace();
>
>              }
>
>       }
>
>
>
> Any idea why this problem?? Is there some error in my code above????
>
>
>
> Please help.
>
> Thank you
>
> M
>
> ------------------------------
>
> *Please consider the environment before printing this email.*
>
> *Visit our website at http://www.nyse.com
> *****************************************************************************
>
> Note: The information contained in this message and any attachment to it is
> privileged, confidential and protected from disclosure. If the reader of
> this message is not the intended recipient, or an employee or agent
> responsible for delivering this message to the intended recipient, you are
> hereby notified that any dissemination, distribution or copying of this
> communication is strictly prohibited. If you have received this
> communication in error, please notify the sender immediately by replying to
> the message, and please delete it from your system. Thank you. NYSE
> Euronext. *
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100616/e4e3dd1a/attachment.html 


More information about the rules-users mailing list