Discussion:
[jboss-user] [jBPM] - How to properly use ContentMarshallerHelper for Human Task Output in JBPM5.3?
Thomas Setiabudi
2012-11-30 02:22:08 UTC
Permalink
Thomas Setiabudi [https://community.jboss.org/people/thomas.setiabudi] created the discussion

"How to properly use ContentMarshallerHelper for Human Task Output in JBPM5.3?"

To view the discussion, visit: https://community.jboss.org/message/779236#779236

--------------------------------------------------------------
Hi,

I have one output on my human task, the output is of type String, and I map this output to one of the process variable.
The problem is, the mapped value becomes:
MarshalledContentWrapper{content=[***@342371e7, marshaller=org.drools.marshalling.impl.SerializablePlaceholderResolverStrategy, type=class java.lang.String}

how to make it resolve correctly to the String value?

here is my code

1. Map<String, Object> taskOutput = new HashMap<String, String>(1);
2.                         taskOutput.put("EvaluationResult",
3.                                         "good");
4.
5.                         ContentData contentData = new ContentData();
6. contentData = ContentMarshallerHelper.marshal(taskOutput,
7.                                         new ContentMarshallerContext(), null);
8.
9. taskClientHelper.completeTask(taskId.longValue(),
10.                                         userId, contentData);


Any help is appreciated.


Best Regards,
Thomas Setiabudi
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/779236#779236]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Maciej Swiderski
2012-11-30 09:06:36 UTC
Permalink
Maciej Swiderski [https://community.jboss.org/people/swiderski.maciej] created the discussion

"Re: How to properly use ContentMarshallerHelper for Human Task Output in JBPM5.3?"

To view the discussion, visit: https://community.jboss.org/message/779283#779283

--------------------------------------------------------------
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
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/779283#779283]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Thomas Setiabudi
2012-11-30 09:48:05 UTC
Permalink
Thomas Setiabudi [https://community.jboss.org/people/thomas.setiabudi] created the discussion

"Re: How to properly use ContentMarshallerHelper for Human Task Output in JBPM5.3?"

To view the discussion, visit: https://community.jboss.org/message/779295#779295

--------------------------------------------------------------
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
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/779295#779295]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Thomas Setiabudi
2012-11-30 10:24:34 UTC
Permalink
Thomas Setiabudi [https://community.jboss.org/people/thomas.setiabudi] created the discussion

"Re: How to properly use ContentMarshallerHelper for Human Task Output in JBPM5.3?"

To view the discussion, visit: https://community.jboss.org/message/779302#779302

--------------------------------------------------------------
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..
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/779302#779302]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Thomas Setiabudi
2012-11-30 15:49:40 UTC
Permalink
Thomas Setiabudi [https://community.jboss.org/people/thomas.setiabudi] created the discussion

"Re: How to properly use ContentMarshallerHelper for Human Task Output in JBPM5.3?"

To view the discussion, visit: https://community.jboss.org/message/779352#779352

--------------------------------------------------------------
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
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/779352#779352]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
星兰 蒋
2012-12-03 14:32:28 UTC
Permalink
星兰 蒋 [https://community.jboss.org/people/jiang_hoo] created the discussion

"Re: How to properly use ContentMarshallerHelper for Human Task Output in JBPM5.3?"

To view the discussion, visit: https://community.jboss.org/message/779641#779641

--------------------------------------------------------------
Hi Thomas,Would you please give me some advice that how you solve this convert issues?I meet the same problems too.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/779641#779641]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Thomas Setiabudi
2012-12-04 01:03:25 UTC
Permalink
Thomas Setiabudi [https://community.jboss.org/people/thomas.setiabudi] created the discussion

"Re: How to properly use ContentMarshallerHelper for Human Task Output in JBPM5.3?"

To view the discussion, visit: https://community.jboss.org/message/779750#779750

--------------------------------------------------------------
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
https://github.com/droolsjbpm/jbpm/blob/master/jbpm-examples/src/main/java/org/jbpm/examples/humantask/HumanTaskExample.java https://github.com/droolsjbpm/jbpm/blob/master/jbpm-examples/src/main/java/org/jbpm/examples/humantask/HumanTaskExample.java

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
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/779750#779750]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
星兰 蒋
2012-12-04 07:46:32 UTC
Permalink
星兰 蒋 [https://community.jboss.org/people/jiang_hoo] created the discussion

"Re: How to properly use ContentMarshallerHelper for Human Task Output in JBPM5.3?"

To view the discussion, visit: https://community.jboss.org/message/779781#779781

--------------------------------------------------------------
Hi, as the example, i get a map like this:

contractno = MarshalledContentWrapper{content=[***@53e36ec6, marshaller=org.drools.marshalling.impl.SerializablePlaceholderResolverStrategy, type=class java.lang.String}
details = MarshalledContentWrapper{content=[***@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. 

--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/779781#779781]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Thomas Setiabudi
2012-12-04 08:01:38 UTC
Permalink
Thomas Setiabudi [https://community.jboss.org/people/thomas.setiabudi] created the discussion

"Re: How to properly use ContentMarshallerHelper for Human Task Output in JBPM5.3?"

To view the discussion, visit: https://community.jboss.org/message/779785#779785

--------------------------------------------------------------
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);

--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/779785#779785]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
星兰 蒋
2012-12-04 08:35:36 UTC
Permalink
星兰 蒋 [https://community.jboss.org/people/jiang_hoo] created the discussion

"Re: How to properly use ContentMarshallerHelper for Human Task Output in JBPM5.3?"

To view the discussion, visit: https://community.jboss.org/message/779792#779792

--------------------------------------------------------------
Thomas,䜠是圚北京吗我们可胜䌚有点䞍同。圚我的案䟋䞭其实我是想圚执行完成任务步骀前获取我启劚流皋时所䌠的参数。我没有䜿甚jbpm console
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/779792#779792]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
星兰 蒋
2012-12-04 08:48:53 UTC
Permalink
星兰 蒋 [https://community.jboss.org/people/jiang_hoo] created the discussion

"Re: How to properly use ContentMarshallerHelper for Human Task Output in JBPM5.3?"

To view the discussion, visit: https://community.jboss.org/message/779795#779795

--------------------------------------------------------------
悚方䟿留䞪电话吗我想电话联系䞋悚沟通䞀䞋。
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/779795#779795]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Thomas Setiabudi
2012-12-04 11:36:31 UTC
Permalink
Thomas Setiabudi [https://community.jboss.org/people/thomas.setiabudi] created the discussion

"Re: How to properly use ContentMarshallerHelper for Human Task Output in JBPM5.3?"

To view the discussion, visit: https://community.jboss.org/message/779837#779837

--------------------------------------------------------------
Hi

I am sorry I cant understand your languange.

If you have different case (used google translate :p )

then maybe you want to open another discussion thread for your case.


Regards,
Thomas Setiabudi
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/779837#779837]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
星兰 蒋
2012-12-04 12:50:38 UTC
Permalink
星兰 蒋 [https://community.jboss.org/people/jiang_hoo] created the discussion

"Re: How to properly use ContentMarshallerHelper for Human Task Output in JBPM5.3?"

To view the discussion, visit: https://community.jboss.org/message/779860#779860

--------------------------------------------------------------
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, processVars);


*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!
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/779860#779860]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Dhaval Shah
2013-01-29 09:51:05 UTC
Permalink
Dhaval Shah [https://community.jboss.org/people/shahdhaval2020] created the discussion

"Re: How to properly use ContentMarshallerHelper for Human Task Output in JBPM5.3?"

To view the discussion, visit: https://community.jboss.org/message/794831#794831

--------------------------------------------------------------
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=[***@1e0d7c5, marshaller=org.drools.marshalling.impl.SerializablePlaceholderResolverStrategy, type=class java.lang.String} Quantity: MarshalledContentWrapper{content=[***@75ffe5, marshaller=org.drools.marshalling.impl.SerializablePlaceholderResolverStrategy, type=class java.lang.String} Priority: MarshalledContentWrapper{content=[***@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
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/794831#794831]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Ouadi BEL
2013-03-26 11:35:34 UTC
Permalink
Ouadi BEL [https://community.jboss.org/people/ouadi_dev] created the discussion

"Re: How to properly use ContentMarshallerHelper for Human Task Output in JBPM5.3?"

To view the discussion, visit: https://community.jboss.org/message/804812#804812

--------------------------------------------------------------
I'm also blocked with this problem, can any one help me to resolve it !!

The problem is described in tis thread :

https://community.jboss.org/message/804254#804254 https://community.jboss.org/message/804254
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/804812#804812]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Loading...