Bug 1257015

Summary: NPE while using global object in a rule
Product: [Retired] JBoss BRMS Platform 6 Reporter: Abhijit humbe <abhumbe>
Component: BREAssignee: Edson Tirelli <etirelli>
Status: CLOSED NOTABUG QA Contact: Marek Winkler <mwinkler>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.1.0CC: abhumbe
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-09-02 16:13:16 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
reproducer none

Description Abhijit humbe 2015-08-26 05:29:41 UTC
Created attachment 1067141 [details]
reproducer

Description of problem:
when we use global objects in rules and try to execute rules through /kie-server it fails with NullPointerException. 
 
~~~
ERROR [org.kie.server.services.rest.KieServerRestImpl] (http-localhost.localdomain/127.0.0.1:8080-6) Error calling container 'project1': Exception executing consequence for rule "TestRule" in defaultpkg: java.lang.NullPointerException
        at org.drools.core.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
. .
~~~
We can execute same rule without any issue through business rule task or through RemoteRestAPI. 

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1. place attached .niogit and repository directories under $JBOSS_HOME/bin directory. 
2.Build project and configure kie-server to execute rules, it fails with NPE.
3. Now try to execute same rule through RemoteREST API's or through Business Rule Task, rule executed without any issue.

Actual results:
Rule execution failed with NPE when we try to execute rule through /kie-server

Expected results:
Rule should executed successfully through /kie-server as well.


Additional info:

Comment 2 Edson Tirelli 2015-08-27 21:04:26 UTC
Abhijit, I am trying to understand what the customer is doing here but I am confused. How is he executing the rules on the kie-server? More specifically, is he using the SetGlobalCommand to set the global before firing the rules?

While the business rules task and remote rest API run collocated with the workbench, the execution server (kie-server) is supposed to run "standalone". This way, it is necessary to set the global as part of the request.

For instance, the following is a valid REST POST body:

POST .../services/rest/server/containers/project1
<batch-execution>
  <set-global identifier="obj">
    <com.redhat.sample.Test/>
  </set-global>
  <fire-all-rules/>
</batch-execution>

It returns the following result:

<response type="SUCCESS" msg="Container project1 successfully called.">
   <results><execution-results/></results>
</response>

Of course, you can use the Java client API to do the same. 

Please let me know if the customer has any other questions.

Comment 5 Abhijit humbe 2015-09-02 16:13:16 UTC
Edson, this issue is resolved after setting global as a part of request payload. 
I am going ahead and closing this bugzilla. Thank you for help.