[rules-users] facing problem in KnowledgeAgent
Michael Anstis
michael.anstis at gmail.com
Wed Apr 17 09:49:10 EDT 2013
What is line 34?
On 17 April 2013 14:04, himansh <himanshsrivastava at 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/testSnapShort2
>
> 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-tp4023368.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20130417/fed0078e/attachment.html
More information about the rules-users
mailing list