[rules-users] java.lang.NullPointerException in simple example

ahgiovanini ahgiovanini at gmail.com
Wed Feb 19 08:08:13 EST 2014


Hi laune, you are right, the ksession is null.

What would be the reason for this? 

The code,
"
>        KieContainer kc =
> KieServices.Factory.get().getKieClasspathContainer(); 
>        KieSession ksession = kc.newKieSession("CashFlowKS"); 
>
" is the original code of example. Maybe I set something wrong in my
project?


My kmodule.xml is:
<?xml version="1.0" encoding="UTF-8"?>
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
	
	<kbase name="kBase">
			<ksession name="CashFlowKS" />		
	</kbase>
</kmodule>

-----------------------------

The rule (CashFlow.drl) is
package com.sample
dialect  "mvel"

rule "Increase balance for AccountPeriod Credits"
when
   ap : AccountPeriod( )
   ac : Account(  )
   cf : CashFlow( type == CashFlowType.CREDIT, accountNo == ac.accountNo,
date >= ap.start && <= ap.end )
then
   ac.balance = ac.balance + cf.amount;
end

rule "Decrease balance for AccountPeriod Debits"
when
   ap : AccountPeriod( )
   ac : Account(  )
   cf : CashFlow( type == CashFlowType.DEBIT, accountNo == ac.accountNo,
date >= ap.start && <= ap.end )
then
   ac.balance = ac.balance - cf.amount;
end

rule "Print blance for AccountPeriod" salience -50
when
       ap : AccountPeriod( )
       ac : Account( )
then
       System.out.println( "Account Number " + ac.accountNo + " balance " +
ac.balance );
end




--
View this message in context: http://drools.46999.n3.nabble.com/java-lang-NullPointerException-in-simple-example-tp4028177p4028193.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list