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

Bug 1072840

Summary: JAXB exception due to serialization of task parameters
Product: [Retired] JBoss BPMS Platform 6 Reporter: Pedro Zapata <pzapataf>
Component: Business CentralAssignee: Marco Rietveld <mrietvel>
Status: CLOSED CURRENTRELEASE QA Contact: Ivo Bek <ibek>
Severity: high Docs Contact:
Priority: high    
Version: 6.0.0CC: agiertli, kverlaen, mbaluch, pzapataf, rrajasek, smcgowan, tlivora, vigoyal
Target Milestone: ER3   
Target Release: 6.0.2   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Sending an object as a parameter to the execute task for a REST service resulted in a SerializationException error. This error only occurred when calling the complete method of TaskService. If CompleteTaskCommand was used and the execute method of KieSession was invoked with this command as a parameter there was no error and the task status was changed to completed. This applied to both REST and JMS. This issue has now been fixed.
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-08-06 19:51:01 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:

Description Pedro Zapata 2014-03-05 09:38:54 UTC
The execute task REST service does not seem to accept objects as parameters. The process instance launch service does.

#1 In business central, clone https://github.com/pzapataf/kie-examples.git
#2 Build and deploy project 'CustomerFollowUp'
#3 In command line, clone https://github.com/pzapataf/kie-examples.git
#4 Build project CustomerFollowUpClient and run CustomerFollowUpClientTest (mvn clean install).


The following exception will be thrown when trying to provice an object of type 'org.jboss.demo.customersatisfaction.Customer' as a task input parameter:

-------------------------------------------
org.kie.services.client.serialization.SerializationException: Unable to marshall JaxbCommandsRequest instance.
	at org.kie.services.client.serialization.JaxbSerializationProvider.serialize(JaxbSerializationProvider.java:101)
	at org.kie.services.client.api.command.AbstractRemoteCommandObject.executeRestCommand(AbstractRemoteCommandObject.java:319)
	at org.kie.services.client.api.command.AbstractRemoteCommandObject.execute(AbstractRemoteCommandObject.java:113)
	at org.jbpm.services.task.impl.command.CommandBasedTaskService.complete(CommandBasedTaskService.java:144)
	at org.jboss.demo.CustomerFollowUpClient.executeNextTask(CustomerFollowUpClient.java:100)
	at org.jboss.demo.CustomerFollowUpClientTest.testEscalationPath(CustomerFollowUpClientTest.java:80)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:76)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: javax.xml.bind.MarshalException

Comment 2 Pedro Zapata 2014-03-05 09:42:47 UTC
As a side note, please not I had to force the following dependency in the client code (pom.xml). Otherwise, there was a mix of 4.1.2 and 4.2.1 versions. Not sure if this was due to some local build problem (even I ran a full build) or a problem with that specific dependency, so it's probably a good idea to double check this. 

<dependency>
   <groupId>org.apache.httpcomponents</groupId>
   <artifactId>httpclient</artifactId>
   <version>4.2.1</version>
</dependency>

Comment 3 Marco Rietveld 2014-03-10 13:30:28 UTC
Hi Pedro, 

In order to be able to send the object back and forth, any custom objects need to be annotated correctly with JAXB annotations. At least @XmlRootElement and @XmlElement must be present. 

See this for an example: 
https://github.com/droolsjbpm/kie-tests/blob/6.0.x/remote-kie-tests/kie-wb-tests/kie-wb-tests-base/src/main/java/org/kie/tests/wb/base/test/objects/MyType.java

The JAXB annotations are neccessary in order to be able to de/serialize the object when receiving or sending it to business-central/kie-wb. 

Pedro, Would you be able to add these annotations and retest? 

---

Also, thanks for pointing out the httpclient deps: I heard a similar comment from someone else recently and will make sure to double check it. 

---

NOTE TO MARCO: Make sure that this is clear in product and community docuemntation!!

Comment 4 Pedro Zapata 2014-03-10 17:42:28 UTC
Hi Marco,

I'll retest with those annotations, but I still wonder why the process launch method does work correctly without the annotations, with the same POJO parameter in.

Shouldn't this be required for this call as well?

Comment 5 Marco Rietveld 2014-03-20 10:35:35 UTC
Pedro, 

I'm pretty sure it just "looks" like the process launch method (KieSession.startProcess( String PROCESS_NAME, Map<String, Object> params)) works. What actually happens is that the object is deserialized to an instance of the org.apache.xerces.dom.ElementNSImpl class on the server side, which is not usable most of the time.

Comment 6 Marco Rietveld 2014-03-25 11:37:09 UTC
Pedro, with regards to the process launch method, see BZ 1078969

Comment 7 Marco Rietveld 2014-03-27 16:54:58 UTC
Pedro, please let me know when you have had a chance to retest this issue.

Comment 11 Tomas Livora 2014-04-10 14:50:35 UTC
I have just tested it again and found out that this problem only occurs when calling complete method of TaskService. If I use CompleteTaskCommand and call execute method of KieSession with this command as a parameter there is no error and task status is changed to completed. This applies to both REST and JMS.

Comment 12 Tomas Livora 2014-04-22 14:46:43 UTC
Why is this BZ's status ON_QA? In previous comments I only mentioned that there is a workaround (executing CompleteTaskCommand). However, it is not possible to complete tasks using TaskService. SerializationException is still present as mentioned in the original Pedro's post. And no fix has been provided so far.

Comment 14 Tomas Livora 2014-04-25 14:06:31 UTC
Since version 6.0.2 ER2 executing CompleteTaskCommand does not work either. ClassCastException is thrown with message 'org.apache.xerces.dom.ElementNSImpl cannot be cast to org.jboss.qa.bpms.jbpm.integration.MyType'.

Comment 15 Marco Rietveld 2014-05-01 20:31:59 UTC
Fixed. Commits: 

6.0.x:
https://github.com/droolsjbpm/droolsjbpm-integration/commit/8ad44c43

master: 
https://github.com/droolsjbpm/droolsjbpm-integration/commit/e874a3fc

***NOTE***: if you are not using the Remote API Java client instances, but are sending JaxbCommandsRequest instances to the ../rest/task/execute URL, you must add a query parameter indicating the deployment id! Otherwise, it will be impossible to determine which deployment the serialized class is available in and to load it for deserialization on the server side. 

In other words, when sending JaxbCommandsRequest instances that concern task or audit commands, please use this URL: "../rest/task/execute?deploymentId=<actual-deployment-id>". Otherwise, simplying using the "../rest/runtime/<actual-deployment-id>/execute URL for all JaxbComandsRequest instances is also fine. 

The Remote Java API client instances now contain this logic as well.

Comment 16 Marco Rietveld 2014-05-08 07:38:11 UTC
Maciej found an NPE hidden in the changes. This is a fix for that: 

master: 
https://github.com/droolsjbpm/droolsjbpm-integration/commit/e54d0851

6.0.x:
https://github.com/droolsjbpm/droolsjbpm-integration/commit/3f2c75fd

Comment 18 Ivo Bek 2014-05-30 14:49:48 UTC
Verified in BPMS 6.0.2.ER3