Bug 745768 - NullPointerException when executing SetGlobalCommand with BatchExecutionCommand when using JPAKnowledgeService.newStatefulKnowledgeSession()
Summary: NullPointerException when executing SetGlobalCommand with BatchExecutionComma...
Keywords:
Status: VERIFIED
Alias: None
Product: JBoss Enterprise BRMS Platform 5
Classification: JBoss
Component: BRE (Expert, Fusion)
Version: BRMS 5.2.0.GA
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
: BRMS 5.3.0.GA
Assignee: Nobody
QA Contact: Lukáš Petrovický
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-10-13 11:00 UTC by Tomas Schlosser
Modified: 2022-11-15 23:14 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
When trying to execute BatchExecutionCommand on a persisted StatefulKnowledgeSession a Null Pointer Exception was thrown. The issue has been resolved by replacing the JPAKnowledgeService.newStatefulKnowledgeSession(kbase, ksconf, env) method, with the kbase.newStatefulKnowledgeSession() method.
Clone Of:
Environment:
Last Closed:
Type: Bug


Attachments (Terms of Use)
Simple reproducer (4.70 KB, application/x-zip-compressed)
2011-10-13 11:00 UTC, Tomas Schlosser
no flags Details

Description Tomas Schlosser 2011-10-13 11:00:22 UTC
Created attachment 527952 [details]
Simple reproducer

Description of problem:
When trying to execute BatchExecutionCommaind on persisted StatefulKnowledgeSession I get NPE.

Version-Release number of selected component (if applicable):
BRMS-5.2.0.CR1

How reproducible:
Every time.

Steps to Reproduce:
1. run included reproducer
  
Actual results:
Exception in thread "main" java.lang.NullPointerException
	at org.drools.command.runtime.rule.QueryCommand.execute(QueryCommand.java:107)
	at org.drools.command.runtime.rule.QueryCommand.execute(QueryCommand.java:36)
	at org.drools.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:155)
	at org.drools.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:76)
	at org.drools.command.impl.DefaultCommandService.execute(DefaultCommandService.java:36)
	at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:331)
	at org.drools.command.impl.CommandBasedStatefulKnowledgeSession.execute(CommandBasedStatefulKnowledgeSession.java:481)
	at org.jboss.qa.brms.persistencequery.PersistenceQueryTest.main(PersistenceQueryTest.java:46)

Expected results:
succesful run

Additional info:

Comment 2 Geoffrey De Smet 2012-01-10 14:15:13 UTC
Would it be possible to add a pom.xml file or all libraries in future reproducer attachments? The missing libraries make it hard to reproduce.

Comment 3 Geoffrey De Smet 2012-01-10 14:20:54 UTC
With drools 5.4.0-SNAPSHOT I am getting this:

{code}
Exception in thread "main" [Error: unable to resolve method: org.jboss.qa.brms.persistencequery.Fact.name__() [arglength=0]]
[Near : {... name == name__ ....}]
             ^
[Line: 1, Column: 1]
	at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:1068)
	at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:982)
	at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getBeanProperty(ReflectiveAccessorOptimizer.java:677)
	at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getBeanPropertyAO(ReflectiveAccessorOptimizer.java:474)
	at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:372)
	at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:141)
	at org.mvel2.optimizers.dynamic.DynamicOptimizer.optimizeAccessor(DynamicOptimizer.java:67)
	at org.mvel2.ast.ASTNode.optimize(ASTNode.java:157)
	at org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:113)
	at org.mvel2.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:116)
	at org.mvel2.compiler.ExecutableAccessor.getValue(ExecutableAccessor.java:42)
	at org.mvel2.MVEL.executeExpression(MVEL.java:922)
	at org.drools.rule.constraint.MvelConditionEvaluator.evaluate(MvelConditionEvaluator.java:34)
	at org.drools.rule.constraint.MvelConditionEvaluator.evaluate(MvelConditionEvaluator.java:30)
	at org.drools.rule.constraint.MvelConstraint.evaluate(MvelConstraint.java:132)
	at org.drools.rule.constraint.MvelConstraint.isAllowedCachedLeft(MvelConstraint.java:101)
	at org.drools.common.DoubleNonIndexSkipBetaConstraints.isAllowedCachedLeft(DoubleNonIndexSkipBetaConstraints.java:136)
	at org.drools.reteoo.JoinNode.assertLeftTuple(JoinNode.java:103)
	at org.drools.reteoo.CompositeLeftTupleSinkAdapter.doPropagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:232)
	at org.drools.reteoo.CompositeLeftTupleSinkAdapter.createAndPropagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:118)
	at org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:158)
	at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
	at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:134)
	at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
	at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:211)
	at org.drools.reteoo.EntryPointNode.assertQuery(EntryPointNode.java:146)
	at org.drools.reteoo.ReteooWorkingMemory.getQueryResults(ReteooWorkingMemory.java:195)
	at org.drools.impl.StatefulKnowledgeSessionImpl.getQueryResults(StatefulKnowledgeSessionImpl.java:770)
	at org.drools.command.runtime.rule.QueryCommand.execute(QueryCommand.java:105)
	at org.drools.command.runtime.rule.QueryCommand.execute(QueryCommand.java:37)
	at org.drools.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:155)
	at org.drools.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:76)
	at org.drools.command.impl.DefaultCommandService.execute(DefaultCommandService.java:36)
	at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:358)
	at org.drools.command.impl.CommandBasedStatefulKnowledgeSession.execute(CommandBasedStatefulKnowledgeSession.java:482)
	at org.jboss.qa.brms.persistencequery.PersistenceQueryTest.main(PersistenceQueryTest.java:46)
{code}

Comment 4 Geoffrey De Smet 2012-01-10 14:33:28 UTC
In drools 5.3.2-SNAPSHOT I am also getting the NPE. The ReflectiveAccessorOptimizer stacktrace might be a different regression in 5.4 related to the MVEL optimization work.

Comment 5 Geoffrey De Smet 2012-01-10 15:34:22 UTC
It looks like the ruleset.drl is invalid.

Instead of
  follows( $middle, next; )
it should be
  ?follows( $middle, next; )

Changing that does not prevent the NPE in 5.3. It probably fixes the ReflectiveAccessorOptimizer in 5.4 (causing an NPE there too?).

Comment 6 Geoffrey De Smet 2012-01-10 16:41:58 UTC
This has nothing to do with the backwards chaining query.
I reproduced it with 
  commands.add(CommandFactory.newSetGlobal("foobar", "boe", true));
with drools 5.4.0-SNAPSHOT.

The problem is the use of
  JPAKnowledgeService.newStatefulKnowledgeSession(kbase, ksconf, env)
Replacing that by
  kbase.newStatefulKnowledgeSession();
stops the issue from occurring.

Comment 7 Geoffrey De Smet 2012-01-10 16:54:38 UTC
I recreated a testcase inside drools-persistence-jpa which only uses SetGlobalCommand:

org.drools.persistence.map.impl.JpaBasedPersistenceTest#testSetGlobalWithJPAKnowledgeService

It's @Ignored atm.

Comment 9 Tomas Schlosser 2012-02-22 08:48:01 UTC
The issue is fixed.

Comment 10 lcarlon 2012-06-01 02:13:16 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
When trying to execute BatchExecutionCommaind on a persisted StatefulKnowledgeSession a Null Pointer Exception is thrown.

Comment 11 lcarlon 2012-06-01 02:45:16 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1 +1 @@
-When trying to execute BatchExecutionCommaind on a persisted StatefulKnowledgeSession a Null Pointer Exception is thrown.+When trying to execute BatchExecutionCommand on a persisted StatefulKnowledgeSession a Null Pointer Exception was thrown. The issue has been resolved by replacing the  JPAKnowledgeService.newStatefulKnowledgeSession(kbase, ksconf, env) method, with the kbase.newStatefulKnowledgeSession() method.


Note You need to log in before you can comment on or make changes to this bug.