What is line 34?
On 17 April 2013 14:04, himansh <himanshsrivastava(a)yahoo.com> wrote:
Hi,
I am new in guvnor, please help me
my code are bellow
package com.sample;
import org.drools.KnowledgeBase;
import org.drools.RuleBase;
import org.drools.WorkingMemory;
import org.drools.agent.KnowledgeAgent;
import org.drools.agent.KnowledgeAgentFactory;
import org.drools.agent.RuleAgent;
import org.drools.definition.KnowledgePackage;
import org.drools.definition.type.FactType;
import org.drools.runtime.StatefulKnowledgeSession;
@SuppressWarnings("restriction")
public class DroolDemo {
/**
* @param args
* @throws IllegalAccessException
* @throws InstantiationException
*/
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"));
}
}
======================================================
Guvnor.properties:
url=
http://localhost:8080/guvnor/org.drools.guvnor.Guvnor/package/org.sample/...
enableBasicAuthentication=true
username=admin
password=admin
name=drooltest
======================================================
Output:
null
null
Exception in thread "main" java.lang.NullPointerException
at com.sample.DroolDemo.main(DroolDemo.java:34)
======================================================
please help me
thanks,
Him
--
View this message in context:
http://drools.46999.n3.nabble.com/facing-problem-in-KnowledgeAgent-tp4023...
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