[rules-users] Could not execute Rules getting NPE

Smurfs smurfs.doll at gmail.com
Fri Aug 30 09:05:32 EDT 2013


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-tp4025731.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list