Bug 1316966

Summary: OSGi: drools-persistence-jpa throws NPE when starting a process via RuntimeManager
Product: [Retired] JBoss BRMS Platform 6 Reporter: Marek Winkler <mwinkler>
Component: BREAssignee: Edson Tirelli <etirelli>
Status: CLOSED EOL QA Contact: Marek Winkler <mwinkler>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.2.0   
Target Milestone: ER3   
Target Release: 6.3.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-03-27 20:13:19 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:
Attachments:
Description Flags
Full stacktrace none

Description Marek Winkler 2016-03-11 14:47:42 UTC
Created attachment 1135261 [details]
Full stacktrace

Description of problem:

When starting a jBPM process using RuntimeManager in OSGi environment, I have to specify in the environment the references to all of the following:
  - EnvironmentName.ENTITY_MANAGER_FACTORY
  - EnvironmentName.TRANSACTION_MANAGER
  - EnvironmentName.TRANSACTION
  - EnvironmentName.TRANSACTION_SYNCHRONIZATION_REGISTRY

If only TransactionManager and EntityManagerFactory are specified, Drools JtaTransactionManager throws the following NPE (see attachment for the full stacktrace):

Caused by: java.lang.NullPointerException
	at org.drools.persistence.jta.JtaTransactionManager.rollback(JtaTransactionManager.java:255)

The root cause might be that it tries to retrieve UserTransaction or TSR from JNDI which fails in OSGi environment (probably different lookup method is needed).

The problem for users is that when using blueprint XML for <kie:environment> definition, the user is not allowed to specify the latter two references (UserTransaction and TSR).

I would probably suggest that:
  1) JtaTransactionManager is able to work even when not all 4 references are set in the Environment,
  2) kie-aries-blueprint allows for specifying UserTransaction and TSR in <kie:environment> in blueprint xml.

If 1) is not possible to achieve, we should at least fix 2).

Version-Release number of selected component (if applicable):
BRMS 6.2.2
Fuse 6.2.1

How reproducible:
always

Steps to Reproduce:
1. run 'mvn clean test -Dtest=KieBlueprintjBPMPersistenceKarafIntegrationTest' from PR https://github.com/droolsjbpm/droolsjbpm-integration/pull/315

Actual results:
The NPE is thrown.

Expected results:
Test passes.

Additional info:
You can uncomment setting of UserTransaction and TSR at org.drools.karaf.itest.beans.ProcessWithPersistenceBean, line 79, and see that the test passes.

Comment 4 Marek Winkler 2016-04-18 14:16:10 UTC
Verified in BRMS 6.3.0 ER3.

It is now possible to declare <kie:environment> element in KIE-Aries-Blueprint XML with the following child elements:
  - <kie:transaction-manager>
  - <kie:transaction-sync-registry>
  - <kie:user-transaction>
  - <kie:entity-manager-factory>

jBPM persistence using environment with all the above properties works in Fuse 6.2.1.