-
1. Re: How to properly use ContentMarshallerHelper for Human Task Output in JBPM5.3?
swiderski.maciej Nov 30, 2012 4:06 AM (in response to thomas.setiabudi)Thomas, please make sure that both sides uses ContentMarshallerHelper to read/write the content. By both sides I mean code that sets the content when completing task and the code that reads it based on the completion event - which is HT work item handler.
HTH
-
2. Re: How to properly use ContentMarshallerHelper for Human Task Output in JBPM5.3?
thomas.setiabudi Nov 30, 2012 4:48 AM (in response to swiderski.maciej)Hi Maciej,
Thank you, I got your point. so because the marshaller and unmarshaller is not the same, the byte array cannot be converted back to String right.
In my case, I use JBPM Console to control the flow. The source code that reads the completion event should be in? AsyncHornetQHTWorkItemHandler?
I still cannot find the code >.<
Regards,
Thomas Setiabudi
-
3. Re: How to properly use ContentMarshallerHelper for Human Task Output in JBPM5.3?
thomas.setiabudi Nov 30, 2012 5:24 AM (in response to swiderski.maciej)I found this lines of code in AsyncWSHumanTaskHandler.java
public void execute(Content content) { Object result = ContentMarshallerHelper.unmarshall( content.getContent(), env); results.put("Result", result); if (result instanceof Map) { @SuppressWarnings("rawtypes") Map<?, ?> map = (Map) result; for (Map.Entry<?, ?> entry : map.entrySet()) { if (entry.getKey() instanceof String) { results.put((String) entry.getKey(), entry.getValue()); } } } manager.completeWorkItem(task.getTaskData().getWorkItemId(), results); }
If this is the code in jbpm console that listens to the task complete event, it means it uses ContentMarshallerHelper too..
-
4. Re: How to properly use ContentMarshallerHelper for Human Task Output in JBPM5.3?
thomas.setiabudi Nov 30, 2012 10:49 AM (in response to thomas.setiabudi)Hi,
Its solved for me now as I switch to JBPM5.4 Final.
in JBPM5.3 Final, I think the cause of my problem is the ContentMarshallerHelper takes a second parameter of type ContentMarshallerContext. this parameter value may be different by the one used by the code who handles completed task.
Regards,
Thomas Setiabudi
-
5. Re: How to properly use ContentMarshallerHelper for Human Task Output in JBPM5.3?
jiang_hoo Dec 3, 2012 9:32 AM (in response to thomas.setiabudi)Hi Thomas,Would you please give me some advice that how you solve this convert issues?I meet the same problems too.
-
6. Re: How to properly use ContentMarshallerHelper for Human Task Output in JBPM5.3?
thomas.setiabudi Dec 3, 2012 8:03 PM (in response to jiang_hoo)Hi,
I moved to jbpm5.4 and it solves the issue since the marshal(..) function only needs 2 arguments now:
I refer to this code
Map<String, Object> results = new HashMap<String, Object>(); results.put("comment", "Agreed, existing laptop needs replacing"); results.put("outcome", "Accept"); ContentData contentData = ContentMarshallerHelper.marshal(results, null); taskClient.complete(task1.getId(), "sales-rep", contentData);
For JBPM5.3 I am not sure if it can be solved by passing null to second marshal(..) function variable. But maybe you can give that a try.
Regards,
Thomas Setiabudi
-
7. Re: How to properly use ContentMarshallerHelper for Human Task Output in JBPM5.3?
jiang_hoo Dec 4, 2012 2:46 AM (in response to thomas.setiabudi)Hi, as the example, i get a map like this:
contractno = MarshalledContentWrapper{content=[B@53e36ec6, marshaller=org.drools.marshalling.impl.SerializablePlaceholderResolverStrategy, type=class java.lang.String}
details = MarshalledContentWrapper{content=[B@787db430, marshaller=org.drools.marshalling.impl.SerializablePlaceholderResolverStrategy, type=class java.lang.String}then,how can i translate them to strings?
the "contractno " and "details " are the vars.
i'm looking forward your reply.
Thanks and Best Regards.
-
8. Re: How to properly use ContentMarshallerHelper for Human Task Output in JBPM5.3?
thomas.setiabudi Dec 4, 2012 3:01 AM (in response to jiang_hoo)Hi,
How do you marshall them?
And how do you unmarshall them?
is the unmarshaller JBPM Console? or you create your own application?
in my case, I created my own taskClient application that calls ContentMarshallerHelper.marshal(results, null);
then it is the jbpm console who calls ContentMarshallerHelper.unmarshal(result, env); -
9. Re: How to properly use ContentMarshallerHelper for Human Task Output in JBPM5.3?
jiang_hoo Dec 4, 2012 3:42 AM (in response to thomas.setiabudi)Thomas,你是在北京吗?我们可能会有点不同。在我的案例中,其实我是想在执行完成任务步骤前获取我启动流程时所传的参数。我没有使用jbpm console
-
10. Re: How to properly use ContentMarshallerHelper for Human Task Output in JBPM5.3?
jiang_hoo Dec 4, 2012 3:48 AM (in response to thomas.setiabudi)您方便留个电话吗?我想电话联系下您沟通一下。
-
11. Re: How to properly use ContentMarshallerHelper for Human Task Output in JBPM5.3?
thomas.setiabudi Dec 4, 2012 6:36 AM (in response to jiang_hoo)Hi
I am sorry I cant understand your languange.
If you have different case (used google translate )
then maybe you want to open another discussion thread for your case.
Regards,
Thomas Setiabudi
-
12. Re: How to properly use ContentMarshallerHelper for Human Task Output in JBPM5.3?
jiang_hoo Dec 4, 2012 7:52 AM (in response to thomas.setiabudi)Hi Thomas, I'm sorry i thought you were in Beijing.
In my case,in fact i want to get the vars's value when i get a task by userid. And these values are passed when i start a processinstance.
i set & get values all in myself application. no using the jbpm console. Also no using marshall and unmarshall.
Set values when start process:
Map<String,Object> params = new HashMap<String,Object>();
params.put("sales", c.getCreateby());
params.put("contractno", c.getContractno());
params.put("details", c.getDetails());
params.put("amount", c.getAmount());
params.put(role.getRole(), leader.getName());
params.put("accoptor", list.get(0).getName());
getSession().startProcess(definitionId, params);
Get values when get a task by userid:
List<TaskSummary> t = sTaskService.getTasksAssignedAsTaskInitiator(idRef, "en-UK");
if(null != t && t.size() > 0){
for(TaskSummary ts : t){
Object obj = getTaskContentInput(ts);
Map<?, ?> map = (Map<?, ?>) obj;
for (Map.Entry<?, ?> entry : map.entrySet()) {
System.out.println(entry.getKey() + " = " + entry.getValue());
}
tasks.add(new TaskRef(ts.getId(), ts.getProcessInstanceId() + "", ts.getProcessId(),
ts.getName(), ts.getCreatedBy().getId(), ts.getStatus() == Status.Suspended, ts.getStatus() != Status.Suspended));
}
}And the getTaskContentInput method as blow:
public Object getTaskContentInput(TaskSummary taskSum) {
BlockingGetTaskResponseHandler handlerT = new BlockingGetTaskResponseHandler();
client.getTask(taskSum.getId(), handlerT);
Task task2 = handlerT.getTask();
TaskData taskData = task2.getTaskData();
BlockingGetContentResponseHandler handlerC = new BlockingGetContentResponseHandler();
client.getContent(taskData.getDocumentContentId(), handlerC);
Content content = handlerC.getContent();
ByteArrayInputStream bais = new ByteArrayInputStream(content.getContent());
try {
ObjectInputStream is = new ObjectInputStream(bais);
Object obj = null;
while ((obj = is.readObject()) != null) {
System.out.println("OBJECT: " + obj);
return obj;
}
} catch (Exception e) {
System.err.print("There was an error reading task input...");
e.printStackTrace();
return null;
}
return null;
}
Is My way right or wrong? Would you pls give some advice?
Thanks and Best Regards!
-
13. Re: How to properly use ContentMarshallerHelper for Human Task Output in JBPM5.3?
shahdhaval2020 Jan 29, 2013 5:31 AM (in response to thomas.setiabudi)Hi even i am facing this issue...... i don't know about marshaller or any thing so can u plz help me
now when it is calling the ftl file on reaCHING HUMAN TASK it is showing this on jsp page
Model Number: MarshalledContentWrapper{content=[B@1e0d7c5, marshaller=org.drools.marshalling.impl.SerializablePlaceholderResolverStrategy, type=class java.lang.String} Quantity: MarshalledContentWrapper{content=[B@75ffe5, marshaller=org.drools.marshalling.impl.SerializablePlaceholderResolverStrategy, type=class java.lang.String} Priority: MarshalledContentWrapper{content=[B@f31cdb, marshaller=org.drools.marshalling.impl.SerializablePlaceholderResolverStrategy, type=class java.lang.String}
and then textboxes and submit button.
when i submit it.
i am getting this output on my console.
Human Task Started....
Exception in thread "Thread-2" java.lang.ClassCastException: java.lang.String cannot be cast to org.jbpm.task.utils.MarshalledContentWrapper
at org.jbpm.task.utils.ContentMarshallerHelper.unmarshall(ContentMarshallerHelper.java:157)
at org.jbpm.process.workitem.wsht.GenericHTWorkItemHandler$TaskCompletedHandler.handleCompletedTask(GenericHTWorkItemHandler.java:208)
at org.jbpm.process.workitem.wsht.GenericHTWorkItemHandler$TaskCompletedHandler$1.run(GenericHTWorkItemHandler.java:187)
at java.lang.Thread.run(Thread.java:679)
how to resolve this issue can u plz help me on this
-
14. Re: How to properly use ContentMarshallerHelper for Human Task Output in JBPM5.3?
ouadi_dev Mar 26, 2013 7:35 AM (in response to thomas.setiabudi)I'm also blocked with this problem, can any one help me to resolve it !!
The problem is described in tis thread :