Getting Null Pointer Exception while calling Droole rules

59 views
Skip to first unread message

praveen...@gmail.com

unread,
Jan 21, 2016, 8:30:37 AM1/21/16
to Drools Usage
hi team,

i developed one rule using declarative model.Now i need to use that rule in java code.I developed standard alone java project.Have alook at my code.

package anil.com;

import org.drools.RuleBase;
import org.drools.WorkingMemory;
import org.drools.agent.RuleAgent;
import org.drools.definition.type.FactType;



public class DroolGuvnor {

public static void main(String[] args) throws InstantiationException,IllegalAccessException{
RuleAgent ruleAgent = RuleAgent.newRuleAgent("/Guvnor.properties");
RuleBase  ruleBase = ruleAgent.getRuleBase();
FactType  factType = ruleBase.getFactType("anil.com.Number");
Object obj = factType.newInstance();
factType.set(obj, "numberone", 2);
factType.set(obj, "numbertwo", 2);
WorkingMemory workingMemory =  ruleBase.newStatefulSession();
workingMemory.insert(obj);
workingMemory.fireAllRules();
System.out.println(factType.get(obj, "message"));
}


properties file:

Guvnor.properties

enableBasicAuthentication=true
username=admin
password=admin
name=kitesystems



Now when i run my java class i am getting following exception.

Exception in thread "main" java.lang.NullPointerException
at java.util.Properties$LineReader.readLine(Unknown Source)
at java.util.Properties.load0(Unknown Source)
at java.util.Properties.load(Unknown Source)
at org.drools.agent.RuleAgent.loadFromProperties(RuleAgent.java:316)
at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:273)
at anil.com.DroolGuvnor.main(DroolGuvnor.java:14)

Help with the mistake i done in my code.

Attaching screenshot of my java  project structure.

thanks,
praveen.
Project_Structure.png
Reply all
Reply to author
Forward
0 new messages