Hi,
I have {Rule1.drl,Rule2,drl,Rule3.brl}
Both the .drl rules run correctly but the .brl does not load and gives me the following
error
I am loading my rules as follows:
private RuleBase loadRules(String[] rules) throws Exception{
PackageBuilder builder = new PackageBuilder();
for ( int i = 0; i < rules.length; i++ ) {
String rulesFiles = rules[i];
//Check the type of rule file, then load it
System.out.println("loading rule file : "+rulesFiles);
loadRuleFile(rulesFiles,builder);
}
Package pkg = builder.getPackage();
RuleBase localRuleBase = RuleBaseFactory.newRuleBase();
localRuleBase.addPackage( pkg );
return localRuleBase;
}
private void loadRuleFile(String rulesFiles,PackageBuilder addRulesToThisPackage ) throws
DroolsParserException, IOException{
int len = rulesFiles.length();
if(rulesFiles.substring((len-4), len).equalsIgnoreCase(".brl")){
BRXMLPersistence read = (BRXMLPersistence) BRXMLPersistence.getInstance();
BRDRLPersistence write = (BRDRLPersistence) BRDRLPersistence.getInstance();
String brl = rulesFiles;
String outputDRL = write.marshal(read.unmarshal(brl));
rulesFiles = outputDRL;
}
Reader source = new InputStreamReader(
RuleRunner.class.getResourceAsStream(rulesFiles) );
//Exception if rule files are not found
if(null==source){
throw new FileNotFoundException("Cannot find rule file:"+rulesFiles);
}
//Load the rules , no DSL
addRulesToThisPackage.addPackageFromDrl(source);
}
I get the following error:
[Fatal Error] :1:1: Content is not allowed in prolog.
Exception in thread "main" com.thoughtworks.xstream.io.StreamException: :
Content is not allowed in prolog.
at com.thoughtworks.xstream.io.xml.DomDriver.createReader(DomDriver.java:65)
at com.thoughtworks.xstream.io.xml.DomDriver.createReader(DomDriver.java:47)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:781)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:773)
at org.drools.brms.server.util.BRXMLPersistence.unmarshal(BRXMLPersistence.java:91)
at com.org.RuleRunner.loadRuleFile(RuleRunner.java:65)
at com.org.RuleRunner.loadRules(RuleRunner.java:42)
at com.org.RuleRunner.runStatelessRules(RuleRunner.java:90)
at com.org.RulesTest.main(RulesTest.java:40)
Caused by: org.xml.sax.SAXParseException: Content is not allowed in prolog.
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at com.thoughtworks.xstream.io.xml.DomDriver.createReader(DomDriver.java:58)
... 8 more
Any Idea?????
Thank you.
M
</pre>
<P><hr size=1></P>
<P><STRONG><font color=green>Please consider the environment before
printing this email.</font></STRONG></P>
<P><STRONG>Visit our website at <a
href="http://www.nyse.com">http://www.nyse.com</a> <br>
*****************************************************************************
<br>
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.
</STRONG></P><pre>
Show replies by date