<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE></TITLE>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2180" name=GENERATOR></HEAD>
<BODY text=#000000 bgColor=#ffffff>
<DIV dir=ltr align=left><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN 
class=490340614-22122008>Here is a unit test you can add to 
PackageBuilderTest:</SPAN></FONT></FONT></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN 
class=490340614-22122008></SPAN></FONT></FONT></FONT>&nbsp;</DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2>&nbsp;&nbsp;&nbsp; 
public void testAddPackage() throws IOException {</FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT>&nbsp;</DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff 
size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; KnowledgeBuilder kbuilder = 
KnowledgeBuilderFactory.newKnowledgeBuilder();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
kbuilder.add(ResourceFactory.newInputStreamResource(this.getClass().getResourceAsStream("mortgages_TEST.pkg")),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
ResourceType.PKG);</FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT>&nbsp;</DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff 
size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; KnowledgeBase kbase = 
KnowledgeBaseFactory.newKnowledgeBase();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
StatefulKnowledgeSession session = 
kbase.newStatefulKnowledgeSession();<BR>&nbsp;&nbsp;&nbsp; }</FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff 
size=2></FONT>&nbsp;</DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff 
size=2></FONT>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=490340614-22122008><FONT face=Arial 
color=#0000ff size=2>The unit test uses the mortgages_TEST from guvnor, you need 
to add mortgages_TEST.pkg to </FONT></SPAN></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN 
class=490340614-22122008>src/test/resources/org.drools.compiler. I have attached 
the mortgages test pkg to this email.</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN 
class=490340614-22122008></SPAN></FONT>&nbsp;</DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN 
class=490340614-22122008>regards</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN 
class=490340614-22122008></SPAN></FONT>&nbsp;</DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN 
class=490340614-22122008>--zoly</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff 
size=2></FONT>&nbsp;</DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> rules-dev-bounces@lists.jboss.org 
[mailto:rules-dev-bounces@lists.jboss.org] <B>On Behalf Of </B>Mark 
Proctor<BR><B>Sent:</B> Monday, December 22, 2008 6:22 AM<BR><B>To:</B> Rules 
Dev List<BR><B>Subject:</B> Re: [rules-dev] possible bug, NPE in 
PackageBuilder.java<BR></FONT><BR></DIV>
<DIV></DIV>Try changing the code to this, let me know if it fixes the problem 
and I'll apply to trunk. any chance you could send us a mini self contained unit 
test for this bug?<BR><BR>&nbsp;&nbsp;&nbsp; public synchronized void 
addPackage(final Package newPkg) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
PackageRegistry pkgRegistry = this.pkgRegistryMap.get( newPkg.getName() 
);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Package pkg = 
null;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( pkgRegistry != null ) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pkg = 
pkgRegistry.getPackage();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
}<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( pkg == null ) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pkg = 
newPackage( new PackageDescr( newPkg.getName() ) 
).getPackage();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR><BR>Zoltan 
Farkas wrote: 
<BLOCKQUOTE 
cite=mid:A483EB3CA9C69D41AEC537D1C7C2CAFF0344553B@34093-C3-EVS2.exchange.rackspace.com 
type="cite">
  <DIV><FONT face=Arial size=2><SPAN 
  class=239251122-18122008>PackageBuilder.java </SPAN></FONT><FONT face=Arial 
  size=2><SPAN class=239251122-18122008>at line 688:</SPAN></FONT></DIV>
  <DIV><FONT face=Arial size=2><SPAN 
  class=239251122-18122008></SPAN></FONT>&nbsp;</DIV>
  <DIV><SPAN class=239251122-18122008><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; 
  public synchronized void addPackage(final Package newPkg) 
  {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  Package pkg = this.pkgRegistryMap.get( newPkg.getName() 
  ).getPackage();<BR></FONT></SPAN></DIV>
  <DIV><SPAN class=239251122-18122008></SPAN>&nbsp;</DIV>
  <DIV><SPAN class=239251122-18122008><FONT face=Arial size=2>if pkgRegistryMap 
  is empty as it should probably be initially adding a new package will cause a 
  NPE.</FONT></SPAN></DIV>
  <DIV><SPAN class=239251122-18122008><FONT face=Arial size=2>This fuction 
  assumes that there is always a package in the 
  packageRegistryMap.</FONT></SPAN></DIV>
  <DIV><SPAN class=239251122-18122008></SPAN>&nbsp;</DIV>
  <DIV><SPAN class=239251122-18122008><FONT face=Arial size=2>I am getting a NPE 
  when I am trying something like:</FONT></SPAN></DIV>
  <DIV><SPAN class=239251122-18122008></SPAN>&nbsp;</DIV>
  <DIV><SPAN class=239251122-18122008><FONT face=Arial 
  size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  KnowledgeBuilder kbuilder = 
  KnowledgeBuilderFactory.newKnowledgeBuilder();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  kbuilder.add(ResourceFactory.newUrlResource("a valid 
  url"),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  ResourceType.PKG);</FONT></SPAN></DIV>
  <DIV><SPAN class=239251122-18122008></SPAN>&nbsp;</DIV>
  <DIV><SPAN class=239251122-18122008><FONT face=Arial size=2>thanks for any 
  help</FONT></SPAN></DIV>
  <DIV><SPAN class=239251122-18122008></SPAN>&nbsp;</DIV>
  <DIV><SPAN class=239251122-18122008><FONT face=Arial 
  size=2>--zoly</FONT></SPAN></DIV><PRE wrap=""><HR width="90%" SIZE=4>
_______________________________________________
rules-dev mailing list
<A class=moz-txt-link-abbreviated href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</A>
<A class=moz-txt-link-freetext href="https://lists.jboss.org/mailman/listinfo/rules-dev">https://lists.jboss.org/mailman/listinfo/rules-dev</A>
  </PRE></BLOCKQUOTE><BR></BODY></HTML>