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