Bug 1050196 - CDIHelper does not take kjar into account during wiringListnerAndWIHs
Summary: CDIHelper does not take kjar into account during wiringListnerAndWIHs
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss BPMS Platform 6
Classification: Retired
Component: jBPM Core
Version: 6.0.0
Hardware: All
OS: All
medium
medium
Target Milestone: ER1
: 6.0.1
Assignee: Mario Fusco
QA Contact: Jiri Svitak
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-01-08 20:18 UTC by Adam Baxter
Modified: 2018-12-04 16:52 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-08-06 20:03:31 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Reproducer code (3.01 KB, text/x-java)
2014-01-09 19:26 UTC, Adam Baxter
no flags Details

Description Adam Baxter 2014-01-08 20:18:37 UTC
Description of problem:

We'd like the kjar contain the WorkItemHandler and KieSession listener classes and load them via the kmodule.xml. Our Environment is set to utilize the KModuleRegisterableItemsFactory. However, during KieSession creation we receive a CNF exception on both instantiating listener and WIH even though the classes are in the kjar. 

Both the Reflection and CDIBean pathways are utilizing Class.forName, which not the kjar's classloader. I imagine MVEL is utilizing something similar.  


Version-Release number of selected component (if applicable):
6.0.0.Final, 6.0.1.Final

How reproducible:
Consistent

Steps to Reproduce:
Example KJAR Project: https://github.com/abaxter-rh4u/jbpm-ee/tree/use_kmodule/jbpm-ee-samples/jbpm-ee-kjar-sample

1. Create RuntimeEnvironment utilizing KModuleRegisterableItemsFactory 
2. Load the container for jbpm-ee-kjar-sample
3. RuntimeEngine engine = rm.getRuntimeEngine(ProcessInstanceIdContext.get());

Actual results:
CNF Exception:
Caused by: java.lang.RuntimeException: Cannot instance WorkItemHandler org.jbpm.ee.test.TestHandler
	at org.drools.compiler.kie.util.CDIHelper.wireListnersAndWIHs(CDIHelper.java:63)
	at org.drools.compiler.kie.util.CDIHelper.wireListnersAndWIHs(CDIHelper.java:26)
	at org.jbpm.runtime.manager.impl.KModuleRegisterableItemsFactory.getWorkItemHandlers(KModuleRegisterableItemsFactory.java:90)
	at org.jbpm.runtime.manager.impl.AbstractRuntimeManager.registerItems(AbstractRuntimeManager.java:78)
	at org.jbpm.runtime.manager.impl.PerProcessInstanceRuntimeManager.getRuntimeEngine(PerProcessInstanceRuntimeManager.java:109)
	at org.jbpm.ee.services.ejb.startup.KnowledgeManagerBean.getRuntimeEngine(KnowledgeManagerBean.java:67)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_45]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_45]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_45]
	at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_45]
	at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72) [jboss-as-ee-7.2.1.Final-redhat-10.jar:7.2.1.Final-redhat-10]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
	at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
	at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:58) [jboss-as-ee-7.2.1.Final-redhat-10.jar:7.2.1.Final-redhat-10]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
	at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:374) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
	at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:129)
	at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:137)
	at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:58) [jboss-as-ee-7.2.1.Final-redhat-10.jar:7.2.1.Final-redhat-10]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
	at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
	at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:58) [jboss-as-ee-7.2.1.Final-redhat-10.jar:7.2.1.Final-redhat-10]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
	at org.jboss.as.ejb3.component.invocationmetrics.ExecutionTimeInterceptor.processInvocation(ExecutionTimeInterceptor.java:43) [jboss-as-ejb3-7.2.1.Final-redhat-10.jar:7.2.1.Final-redhat-10]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
	at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:374) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
	at org.jboss.as.ejb3.concurrency.ContainerManagedConcurrencyInterceptor.processInvocation(ContainerManagedConcurrencyInterceptor.java:104) [jboss-as-ejb3-7.2.1.Final-redhat-10.jar:7.2.1.Final-redhat-10]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
	at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:74)
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
	at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
	at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
	at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53) [jboss-as-ee-7.2.1.Final-redhat-10.jar:7.2.1.Final-redhat-10]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
	at org.jboss.as.ejb3.component.singleton.SingletonComponentInstanceAssociationInterceptor.processInvocation(SingletonComponentInstanceAssociationInterceptor.java:52) [jboss-as-ejb3-7.2.1.Final-redhat-10.jar:7.2.1.Final-redhat-10]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
	at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:226) [jboss-as-ejb3-7.2.1.Final-redhat-10.jar:7.2.1.Final-redhat-10]
	... 177 more
Caused by: java.lang.ClassNotFoundException: org.jbpm.ee.test.TestHandler from [Module "deployment.jbpm-ee-services.war:main" from Service Module Loader]
	at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:196) [jboss-modules.jar:1.2.2.Final-redhat-1]
	at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:444) [jboss-modules.jar:1.2.2.Final-redhat-1]
	at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:432) [jboss-modules.jar:1.2.2.Final-redhat-1]
	at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:374) [jboss-modules.jar:1.2.2.Final-redhat-1]
	at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:119) [jboss-modules.jar:1.2.2.Final-redhat-1]
	at java.lang.Class.forName0(Native Method) [rt.jar:1.7.0_45]
	at java.lang.Class.forName(Class.java:190) [rt.jar:1.7.0_45]
	at org.drools.compiler.kie.util.CDIHelper$CDIBeanCreator.createBean(CDIHelper.java:109)
	at org.drools.compiler.kie.util.CDIHelper.wireListnersAndWIHs(CDIHelper.java:61)
	... 214 more

Expected results:
The classes to load correctly

Additional info:
My branch of the jBPM-EE project causing this error is https://github.com/abaxter-rh4u/jbpm-ee/tree/use_kmodule

Comment 2 Adam Baxter 2014-01-09 19:26:08 UTC
Created attachment 847784 [details]
Reproducer code

Hey Mario,

I tried to create the reproducer like you asked, but Eclipse is giving me some bizarre problems. 

This is as close as I could get. It matches up with what we're doing in our code.

Comment 4 Adam Baxter 2014-01-10 16:11:17 UTC
Additional notes:

Simply modifying the instances of Class.forName() to Thread.currentThread().getContextClassLoader() would be enough for the CDI and Reflection pathways in CDIHelper, but that requires the ContextClassLoader be set manually from above jBPM. 

I was able to get the MVEL pathway working only if the WIH/Listener entry was "Thread.currentThread().getContextClassLoader().loadClass("org.jbpm.ee.test.TestHandler").newInstance();" However, this prevents us from utilizing the ksession, etc... identifiers in the constructor.

Adam

Comment 5 Mario Fusco 2014-01-14 18:19:12 UTC
Fixed by https://github.com/droolsjbpm/drools/commit/5f7896d61

Comment 6 Adam Baxter 2014-03-07 16:34:44 UTC
Yes, this problem is fixed.

Comment 7 Jiri Svitak 2014-03-07 16:48:18 UTC
Thanks Adam for checking!

Verified in BPMS 6.0.1.ER2.


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