JBoss Community

Re: java.lang.String cannot be cast to org.jbpm.task.utils.MarshalledContentWrapper

created by kifayath khan in jBPM - View the full discussion

I am also getting same error , i am putting my code and error. Please help me

 

 

package com.sample;

 

 

import java.util.HashMap;

import java.util.Map;

 

 

import org.drools.KnowledgeBase;

import org.drools.builder.KnowledgeBuilder;

import org.drools.builder.KnowledgeBuilderFactory;

import org.drools.builder.ResourceType;

import org.drools.io.ResourceFactory;

import org.drools.logger.KnowledgeRuntimeLogger;

import org.drools.logger.KnowledgeRuntimeLoggerFactory;

import org.drools.runtime.StatefulKnowledgeSession;

import org.jbpm.process.workitem.wsht.HornetQHTWorkItemHandler;

 

 

/**

* This is a sample file to launch a process.

*/

public class ProcessTest {

 

 

          public static final void main(String[] args) {

                    try {

                              // load up the knowledge base

                              KnowledgeBase kbase = readKnowledgeBase();

                              StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);

                              KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newThreadedFileLogger(ksession, "test", 1000);

                              // start a new process instance

                              Map<String, Object> params = new HashMap<String, Object>();

                              params.put("employee", "krisv");

                              params.put("reason", "Yearly performance evaluation");

                              ksession.startProcess("com.sample.evaluation", params);

                              System.out.println("Process started ...");

                              logger.close();

                    } catch (Throwable t) {

                              t.printStackTrace();

                    }

          }

 

 

          private static KnowledgeBase readKnowledgeBase() throws Exception {

                    KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

                    kbuilder.add(ResourceFactory.newClassPathResource("Evaluation.bpmn"), ResourceType.BPMN2);

                    return kbuilder.newKnowledgeBase();

          }

 

          private static StatefulKnowledgeSession createKnowledgeSession(KnowledgeBase kbase) {

                    StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

                    HornetQHTWorkItemHandler humanTaskHandler = new HornetQHTWorkItemHandler(ksession);

                    humanTaskHandler.setIpAddress("127.0.0.1");

                    humanTaskHandler.setPort(5445);

                    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", humanTaskHandler);

                    return ksession;

          }

 

 

 

}

 

 

When I ran the code above, the first task executed fine, but the second task gives me:

     java.lang.String cannot be cast to org.jbpm.task.utils.MarshalledContentWrapper

 

Process started ...

Exception in thread "Thread-3" 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:722)

 

Reply to this message by going to Community

Start a new discussion in jBPM at Community