Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1096087

Summary: Classloading issues when using 3rd party libraries in custom WorkItemHandler
Product: [Retired] JBoss BPMS Platform 6 Reporter: Martin Weiler <mweiler>
Component: jBPM CoreAssignee: Alessandro Lazarotti <alazarot>
Status: CLOSED EOL QA Contact: Marek Baluch <mbaluch>
Severity: high Docs Contact:
Priority: high    
Version: 6.0.1CC: ajuricic, kverlaen, rrajasek
Target Milestone: DR2   
Target Release: 6.1.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:06:49 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 application none

Description Martin Weiler 2014-05-09 08:43:47 UTC
Description of problem:
Running a process with a custom workitem handler that is using JAXB marshalling fails with the following exception:

ERROR [stderr] (http-/127.0.0.1:8080-4) javax.xml.bind.JAXBException: ClassCastException: attempting to cast jar:file:/C:/servers/jboss-eap-6.1/modules/system/layers/base/javax/xml/bind/api/main/jboss-jaxb-api_2.2_spec-1.0.4.Final-redhat-2.jar!/javax/xml/bind/JAXBContext.class to jar:file:/C:/Program%20Files/Java/jdk1.7.0_51/jre/lib/rt.jar!/javax/xml/bind/JAXBContext.class.  Please make sure that you are specifying the proper ClassLoader.

17:56:55,620 ERROR [stderr] (http-/127.0.0.1:8080-4) 	at javax.xml.bind.ContextFinder.handleClassCastException(ContextFinder.java:115)
17:56:55,620 ERROR [stderr] (http-/127.0.0.1:8080-4) 	at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:251)
17:56:55,620 ERROR [stderr] (http-/127.0.0.1:8080-4) 	at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:235)
17:56:55,621 ERROR [stderr] (http-/127.0.0.1:8080-4) 	at javax.xml.bind.ContextFinder.find(ContextFinder.java:432)
17:56:55,621 ERROR [stderr] (http-/127.0.0.1:8080-4) 	at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:637)
17:56:55,622 ERROR [stderr] (http-/127.0.0.1:8080-4) 	at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:584)
17:56:55,622 ERROR [stderr] (http-/127.0.0.1:8080-4) 	at com.sample.WorkItemHandler.executeWorkItem(WorkItemHandler.java:51)


Using Apache HttpClient libraries like this:

    StringEntity input = new StringEntity(request);
    input.setContentType("application/xml");
    postRequest.setEntity(input);
    HttpResponse response = httpClient.execute(postRequest);

fails with the following error:

Process Instances failed to start: java.lang.LinkageError:loader constraint violation: when resolving method "org.apache.http.client.methods.HttpPost.setEntity(Lorg/apache/http/HttpEntity;)V" the class loader (instance of org/drools/core/common/ProjectClassLoader$InternalTypesClassLoader) of the current class, com/jbpm/jaxb/workitem/SendWordWorkItemHandler, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for resolved class, org/apache/http/client/methods/HttpPost, have different Class objects for the type tp/HttpEntity;)V used in the signature

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


How reproducible:
Always


Steps to Reproduce:
1.
2.
3.

Actual results:
Process can be executed.

Expected results:
Process execution fails with the aformentioned exceptions.


Additional info:

Comment 2 Martin Weiler 2014-05-12 15:35:06 UTC
Created attachment 894772 [details]
Reproducer application

Attaching reproducer application - see included readme.txt file for instructions.

Comment 3 Mario Fusco 2014-05-13 16:38:52 UTC
Reassigning to Maciej so he could check if kie-ci is causing this issue (at the moment we don't think so).

Comment 4 Maciej Swiderski 2014-05-14 12:39:57 UTC
it was caused by lack of parent class loader in InternalTypesClassLoader and thus accessing classes directly in JDK instead of going through app server.

Tested with both kie-wb (with and without jboss modules) though I was not able to reproduce the http client issue at all.

Committed only to master as it has no blocker flag set, if it is required to be in 6.0.x please set blocker flag and I'll back port it.

drools
master:
https://github.com/droolsjbpm/drools/commit/8a478ea084bc95d0516411caed42db197f386f93

Comment 6 Jiri Svitak 2014-09-09 18:34:07 UTC
Since this issue is quite complicated to verify, I followed the steps in readme.txt file of the attachment. Maybe the component is wrong and should be business central instead due to app server classloader involved. No exceptions were thrown and both handlers seem to work as expected:

20:14:51,526 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: JBoss BPM Suite 6.1.0.Alpha (AS 7.4.0.Final-redhat-19) started in 40978ms - Started 1074 of 1111 services (78 services are lazy, passive or on-demand)
20:24:15,108 INFO  [org.drools.compiler.kie.builder.impl.KieRepositoryImpl] (http-localhost.localdomain/127.0.0.1:8080-6) KieModule was added:ZipKieModule[ ReleaseId=com.jbpm.test:ClassloadingTest:0.0.1-SNAPSHOTfile=/home/jsvitak/.m2/repository/com/jbpm/test/ClassloadingTest/0.0.1-SNAPSHOT/ClassloadingTest-0.0.1-SNAPSHOT.jar]
20:24:15,556 INFO  [org.jbpm.kie.services.impl.store.DeploymentSynchronizer] (http-localhost.localdomain/127.0.0.1:8080-6) Deployment unit com.jbpm.test:ClassloadingTest:0.0.1-SNAPSHOT [strategy=SINGLETON] stored successfully
20:24:54,578 INFO  [com.jbpm.test.TestHttpClientWorkItemHandler] (http-localhost.localdomain/127.0.0.1:8080-5) >>> setEntity : 
20:25:31,307 INFO  [com.jbpm.test.TestJaxbWorkItemHandler] (http-localhost.localdomain/127.0.0.1:8080-5) *** execute work item ***
20:25:31,310 INFO  [com.jbpm.test.TestJaxbWorkItemHandler] (http-localhost.localdomain/127.0.0.1:8080-5) JAXBContext successfully created

Verified in BPMS 6.1.0.DR2.