<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
I have successfully used DRLParser with several DRL files, except when they include the 'contains' syntax. My code for parsing DRL and then dumping into XML, is below:<br><br>public class DroolsDumper {<br><br> public static final void main(String[] args) throws DroolsParserException {<br> DrlParser parser = new DrlParser();<br> PackageDescr descr = parser.parse(new InputStreamReader(DroolsDumper.class.getResourceAsStream("/source.drl" )));<br><br> // Dump to xml rule.<br> XmlDumper dumper = new XmlDumper();<br> String result = dumper.dump(descr);<br> System.out.println(result); <br>}}<br><br>This code returns the following error when the DRL includes 'contains' syntax:<br><br>Exception in thread "main" java.lang.NullPointerException<br> at org.drools.xml.XmlDumper.visitPackageDescr(XmlDumper.java:224)<br> at org.drools.xml.XmlDumper.dump(XmlDumper.java:71)<br> at com.sample.DroolsDumper.main(DroolsDumper.java:19)<br><br>This code works fine with the following DRL (whether I dump the parsed DRL into XML or back into DRL):<br><br>rule 'cart rule'<br>dialect "mvel"<br>when<br>Cart ()<br>then<br>System.out.println("Hello World");<br>end <br><br>But it returns the above error when the same DRL includes 'contains':<br><br>rule 'cart rule'<br>
dialect "mvel"<br>
when<br>
Cart (skus contains (123))<br>
then<br>
System.out.println("Hello World");<br>
end <br><br>The DRL works fine in test scenarios and my cart class's array is declared simply as follows:<br><br>package shopping;<br>import java.util.ArrayList;<br>public class Cart {<br>public ArrayList<Integer> skus = new ArrayList<Integer>();<br>public ArrayList<Integer> getSkus() {<br> return skus;<br>}<br>public void setSkus(ArrayList<Integer> skus) {<br> this.skus = skus;<br>}<br>}<br>                                            </body>
</html>