[rules-users] Can't access binary rules package in application

kissro at lidp.com kissro at lidp.com
Tue Sep 11 09:17:11 EDT 2007


Using BRMS, I created a rule binary package and downloaded it and am
trying to access it but I'm getting a NullPointerException.  My code
looks like this - 

 public void main(Policy inputPolicy) throws Exception
 {
    RuleBase ruleBase = loadRuleBase();
    StatefulSession session = ruleBase.newStatefulSession();
    session.insert(inputPolicy);
    session.fireAllRules();
 }

 private RuleBase loadRuleBase() throws IOException, Exception
 {
    BinaryRuleBaseLoader loader = new BinaryRuleBaseLoader();
    loader.addPackage( this.getClass().getResourceAsStream(
                                       "/underwriting.pkg" ) );
    RuleBase ruleBase = loader.getRuleBase();

    return ruleBase;
  }

I'm getting the following error.  Can someone tell me what I'm doing
wrong?  Do I have something coded incorrectly?

Exception in thread "main" javax.ejb.EJBException:
java.lang.NullPointerException
        at
org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:63)
        at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
        at
org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
        .
        .
        .
Caused by: java.lang.NullPointerException
        at
org.drools.util.BinaryRuleBaseLoader.addPackage(BinaryRuleBaseLoader.java:105)
        at
org.drools.util.BinaryRuleBaseLoader.addPackage(BinaryRuleBaseLoader.java:67)
        at
com.lidp.server.session.UnderwritingRule.loadRuleBase(UnderwritingRule.java:59)
        at
com.lidp.server.session.UnderwritingRule.main(UnderwritingRule.java:20)
        at
com.lidp.server.session.RuleProcessEngine.underwriting(RuleProcessEngine.java:42)



More information about the rules-users mailing list