Without line numbers we can but guess.
I'd gamble that the NPE relates to not being able to find
/Guvnor.properties on your class path.
On 30 August 2013 14:05, Smurfs <smurfs.doll(a)gmail.com> wrote:
Hi
I am new to Drools. I am using a maven project to connect to guvnor and
execute the rules.
pom.xml
-----------
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>5.5.0.Final</version>
</dependency>
Code
-----
public static void main(String[] args) throws InstantiationException,
IllegalAccessException {
KnowledgeAgent ruleAgent =
KnowledgeAgentFactory.newKnowledgeAgent("/Guvnor.properties");
System.out.println(ruleAgent.getKnowledgeBase().getFactType("org.sample","NumberTest"));
KnowledgeBase ruleBase = ruleAgent.getKnowledgeBase();
System.out.println(ruleBase.getFactType("org.sample","NumberTest"));
FactType factType = ruleBase.getFactType("org.sample",
"NumberTest");
Object obj = factType.newInstance();
factType.set(obj, "numberone", 2);
factType.set(obj, "numbertwo", 1);
StatefulKnowledgeSession workingMemory =
ruleBase.newStatefulKnowledgeSession();
workingMemory.insert(obj);
workingMemory.fireAllRules();
System.out.println(factType.get(obj, "message"));
}
I am getting the null pointer exception as below:
null
Exception in thread "main" java.lang.NullPointerException
at com.test.drools.guvnor.App.main(App.java:44)
I know, that many people has raised this issue, can anyone know why it is
causing the issue?
Thanks
Smurfs
--
View this message in context:
http://drools.46999.n3.nabble.com/Could-not-execute-Rules-getting-NPE-tp4...
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users