Bug 1024596

Summary: JTA LocalTaskService fails in WebSphere
Product: [JBoss] JBoss Enterprise BRMS Platform 5 Reporter: Toshiya Kobayashi <tkobayas>
Component: jBPM 5Assignee: Kris Verlaenen <kverlaen>
Status: NEW --- QA Contact: Radovan Synek <rsynek>
Severity: high Docs Contact:
Priority: unspecified    
Version: BRMS 5.3.1   
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: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Toshiya Kobayashi 2013-10-30 03:24:14 UTC
Description of problem:

If a user application uses LocalTaskService with transaction-type="JTA" persistence-unit, org.jbpm.task.service.TaskService.createSession() fails with NameNotFoundException.

[10/17/13 18:17:33:092 IST] 000000ea SystemOut     O 18:17:33,092 ERROR TaskService:429 - Unable to find transaction: A JNDI operation on a "java:" name cannot be completed because the server runtime is not able to associate the operation's thread with any J2EE application component.  This condition can occur when the JNDI client using the "java:" name is not executed on the thread of a server application request.  Make sure that a J2EE application does not execute JNDI operations on "java:" names within static code blocks or in threads created by that J2EE application.  Such code does not necessarily run on the thread of a server application request and therefore is not supported by JNDI operations on "java:" names.
java.lang.IllegalStateException: Unable to find transaction: A JNDI operation on a "java:" name cannot be completed because the server runtime is not able to associate the operation's thread with any J2EE application component.  This condition can occur when the JNDI client using the "java:" name is not executed on the thread of a server application request.  Make sure that a J2EE application does not execute JNDI operations on "java:" names within static code blocks or in threads created by that J2EE application.  Such code does not necessarily run on the thread of a server application request and therefore is not supported by JNDI operations on "java:" names.
        at org.drools.persistence.jta.JtaTransactionManager.findUserTransaction(JtaTransactionManager.java:124)
        at org.drools.persistence.jta.JtaTransactionManager.<init>(JtaTransactionManager.java:69)
        at org.jbpm.task.service.persistence.TaskJTATransactionManager.<init>(TaskJTATransactionManager.java:37)
        at org.jbpm.task.service.persistence.TaskSessionFactoryImpl.createTaskPersistenceManager(TaskSessionFactoryImpl.java:85)
        at org.jbpm.task.service.persistence.TaskSessionFactoryImpl.createTaskServiceSession(TaskSessionFactoryImpl.java:75)
        at org.jbpm.task.service.TaskService.createSession(TaskService.java:203)
        at org.jbpm.task.service.TaskService.executeEscalatedDeadline(TaskService.java:288)
        at org.jbpm.task.service.TaskService$ScheduledTaskDeadline.call(TaskService.java:426)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:314)
        at java.util.concurrent.FutureTask.run(FutureTask.java:149)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:109)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:217)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:897)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:919)
        at java.lang.Thread.run(Thread.java:770)
Caused by: javax.naming.ConfigurationException: A JNDI operation on a "java:" name cannot be completed because the server runtime is not able to associate the operation's thread with any J2EE application component.  This condition can occur when the JNDI client using the "java:" name is not executed on the thread of a server application request.  Make sure that a J2EE application does not execute JNDI operations on "java:" names within static code blocks or in threads created by that J2EE application.  Such code does not necessarily run on the thread of a server application request and therefore is not supported by JNDI operations on "java:" names. [Root exception is javax.naming.NameNotFoundException: Name "comp/UserTransaction" not found in context "java:".]
        at com.ibm.ws.naming.java.javaURLContextImpl.throwExceptionIfDefaultJavaNS(javaURLContextImpl.java:522)
        at com.ibm.ws.naming.java.javaURLContextImpl.throwConfigurationExceptionWithDefaultJavaNS(javaURLContextImpl.java:552)
        at com.ibm.ws.naming.java.javaURLContextImpl.lookupExt(javaURLContextImpl.java:481)
        at com.ibm.ws.naming.java.javaURLContextRoot.lookupExt(javaURLContextRoot.java:485)
        at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:370)
        at org.apache.aries.jndi.DelegateContext.lookup(DelegateContext.java:161)
        at javax.naming.InitialContext.lookup(InitialContext.java:436)
        at org.drools.persistence.jta.JtaTransactionManager.findUserTransaction(JtaTransactionManager.java:119)
        ... 14 more
Caused by: javax.naming.NameNotFoundException: Name "comp/UserTransaction" not found in context "java:".
        at com.ibm.ws.naming.ipbase.NameSpace.lookupInternal(NameSpace.java:1228)
        at com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpace.java:1141)
        at com.ibm.ws.naming.urlbase.UrlContextImpl.lookupExt(UrlContextImpl.java:1436)
        at com.ibm.ws.naming.java.javaURLContextImpl.lookupExt(javaURLContextImpl.java:477)
        ... 19 more

Steps to Reproduce:
1. Use persistence.xml with transaction-type="JTA"
2. Instantiate a LocalTaskService
Environment env = ksession.getEnvironment();
EntityManagerFactory emf = (EntityManagerFactory) env.get(EnvironmentName.ENTITY_MANAGER_FACTORY);
org.jbpm.task.service.TaskService taskService = new org.jbpm.task.service.TaskService(emf, SystemEventListenerFactory.getSystemEventListener());
LocalTaskService localTaskService = new LocalTaskService(taskService);

Actual results:

javax.naming.NameNotFoundException: Name "comp/UserTransaction" not found in context "java:".

Expected results:

No exception

Comment 1 Toshiya Kobayashi 2013-10-30 03:28:04 UTC
I think TaskJTATransactionManager requires special care like ContainerManagedTransactionManager in BZ833609

Comment 2 Toshiya Kobayashi 2013-10-30 03:28:55 UTC
jbpm-human-task.war uses RESOURCE_LOCAL persistence-unit so doesn't hit the issue.