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

Bug 1101433

Summary: CNFE when calling getContent via remote api for Custom Objects
Product: [Retired] JBoss BPMS Platform 6 Reporter: Anton Giertli <agiertli>
Component: jBPM CoreAssignee: Alessandro Lazarotti <alazarot>
Status: CLOSED EOL QA Contact: Ivo Bek <ibek>
Severity: high Docs Contact:
Priority: high    
Version: 6.0.2CC: alazarot, mbaluch, mbiarnes, rzhang
Target Milestone: ER3   
Target Release: 6.0.2   
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:05 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
[1] git repository to be cloned into the business-central
none
[2] remote client
none
[3] server.log from start till the exception none

Description Anton Giertli 2014-05-27 07:55:29 UTC
Description of problem:

ClassNotFoundException occurs upon this call

Content content = taskService.getContentById(task.getTaskData()
					.getDocumentContentId());

taskService was created like this:

restSessionFactory = new RemoteRestRuntimeFactory(deploymentId,bpmsUrl,username,password);
engine = restSessionFactory.newRuntimeEngine();
taskService = engine.getTaskService();

It is specific for
 -- java remote api calls
 -- when the process uses custom objects -- i.e. this object is mapped into the Task

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

BPM Suite 6.0.0
BPM Suite 6.0.1
How reproducible:
always

Steps to Reproduce:
1. Clone attached git repository into running BPM instance.
At this point you might want to alter Task actor so it suits your environment.

2. Import attached client project into your favourite IDE.
At this point you might want to alter
/bpms/src/main/resources/bpm-env.properties so it suits your BPM environment
Also, alter
bpms/src/main/java/nets/mor/common/process/BpmMain.java
line 36
bpmService.startTask(taskId, "anton");
change the actor id, so it matches the task actor which you have configured in the step 1
3. Now you are ready to go, execute Main.
/bpms/src/main/java/nets/mor/common/process/BpmMain.java

By default, the Custom Object is created by Data Modeler and it is included directly in the project kjar. However, I have tried the following and it did not help:

-- delete this Data Modeler Custom Object
-- model it in the IDE -/bpms/src/main/java/com/redhat/qa/bpms/Application.java
-- export this class to the jar
-- add kmodule.xml under META-INF in this jar
-- upload this jar to the artifact repository
-- add this jar to the project dependency in the business-central

What helped is a workaround described at the end of the "Additional Info" section.

Actual results:
CNFE occurs when calling getContent via remote api for a task which includes Custom Objects

Expected results:
Content is properly retrieved when calling getContent via remote api for a task which includes Custom Objects


Additional info:
Investigation report provided by Maciej:
"the issue is caused by when using remote api and getContent method of TaskService it attempts to unmarshal data into the object while it should not. The getContent method is suppose to return “raw” content of the task data and caller is responsible in unmarshalling this - exactly as it’s done in the reproducer code. To give you bit more details on what’s going on and why the workaround found by you works:
- getContent method accepts only single parameter which is content id, 
- that in turn does not provide enough information to be able to figure out what project (deployment unit) content belongs to - would require additional query to db to find that out which would be inefficient as caller to be able to invoke getContent method need to already know the task (and by that deployment unit) so it would be double work
- with just content id engine cannot unmarshal the content data (bytes) into objects as it does not have correct class loader and marshaling strategies at hand
- since there is no specific to deployment unit class loader it uses the one available which is application class loader (in case modules are used module class loader)
- that’s why by placing client’s jar into modules make it to work

and now the most important - getContent method should not care about unmarshaling as it’s just returns content as bytes and let caller deal with unmarshaling. Does that make sense to you?

 By removing the unmarshaling from this method your reproducer worked without any issue"
=========================
The workaround Maciej is referring to consists of adding these Custom Objects in a jar and registering them into JBoss Module, does not really matter which one, i.e. org.kie.lib module (also module.xml needs to be updated)

Comment 1 Anton Giertli 2014-05-27 07:56:34 UTC
Created attachment 899399 [details]
[1] git repository to be cloned into the business-central

Comment 3 Anton Giertli 2014-05-27 08:03:48 UTC
Created attachment 899402 [details]
[2] remote client

Comment 4 Anton Giertli 2014-05-27 08:04:25 UTC
Created attachment 899403 [details]
[3] server.log from start till the exception

Comment 13 Michael 2014-05-27 16:48:27 UTC
commits cherry-picked to 6.0.2.ER3 -->

droolsjbpm-knowledge:   5a57a547172ce9a4a06a93f16f8eca9e8978800a
jbpm:                   8fa48bd53bfe9e257a08f629073d2056e78788eb
droolsjbpm-integration: 07f5d38818122ae3628ac96705e4a65e5eaff5c6

Comment 15 Ivo Bek 2014-06-08 11:09:48 UTC
Verified in BPMS 6.0.2.ER3