Hmmm.... Rikkola can't replicate so something is broken here.... :(<br><br><div class="gmail_quote">On 28 April 2011 13:42, Michael Anstis <span dir="ltr"><<a href="mailto:michael.anstis@gmail.com">michael.anstis@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Hi,<br><br>This boiler plate code demonstrates a rather, I suspect large, problem:-<br><br><span style="font-family: courier new,monospace;">@Test</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> public void testPackageAttributesFromDRL() {</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> kbuilder.add( new ClassPathResource( "org/drools/example.drl" ), </span><span style="font-family: courier new,monospace;">ResourceType.DRL ); //<--- Error</span><br>
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">}</span><br><br>throws:-<br><br><span style="font-family: courier new,monospace;">java.lang.NullPointerException</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> at org.drools.compiler.PackageBuilder.generateDeclaredBean(PackageBuilder.java:1433)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> at org.drools.compiler.PackageBuilder.processTypeDeclarations(PackageBuilder.java:1272)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> at org.drools.compiler.PackageBuilder.mergePackage(PackageBuilder.java:895)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> at org.drools.compiler.PackageBuilder.newPackage(PackageBuilder.java:883)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:601)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:297)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:473)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:28)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> at org.drools.BinaryPackage.testPackageAttributesFromDRL(BinaryPackage.java:35)</span><br>
<br>In <span style="font-family: courier new,monospace;">org.drools.compiler.PackageBuilder.generateDeclaredBean</span> the call to the following returns null.<br><br>JavaDialectRuntimeData dialect = (JavaDialectRuntimeData) pkgRegistry.getDialectRuntimeRegistry().getDialectData( "java" );<br>
<br>DRL is:-<br><br><span style="font-family: courier new,monospace;">package example</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">declare Person</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> age: Integer</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> name: String</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">end</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">rule "Row 1 dtable"</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> salience 1</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> dialect "mvel"</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> when</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> $p : Person( name == "Bill" , age != "30" )</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> then</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> $p.setAge( 12345 );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">end</span><br><br>It worked OK yesterday.<br><br>Any takers?<br><br>With kind regards,<br><br>Mike<br>
</blockquote></div><br>