AnsweredAssumed Answered

How to extend ServiceTask properly?

Question asked by viggo.navarsete on Jan 3, 2014
Latest reply on Jan 4, 2014 by viggo.navarsete

I started to create processes programatically inspired by this forum post:

I see that I probably need various service tasks in Java where I need to set some common properties like this:
protected FlowElement createServiceTask(String id, String name) {
      ServiceTask serviceTask = new ServiceTask();
     return serviceTask;

This work perfectly well if I do it like above, but then I thought I could move most of this code into a base class which extends ServiceTask, like this:
public class CreatePurchaseOrderServiceTask extends ServiceTask {

    public CreatePurchaseOrderServiceTask(String id) {  
        setName("Create Purchase Order Task");

and call it like this:
protected FlowElement createServiceTask(String id, String name) {
     CreatePurchaseOrderServiceTask serviceTask = new CreatePurchaseOrderServiceTask(id);  
     return serviceTask;

but then I end up with this stacktrace:
03 Jan 2014 17:45:34 ERROR BpmnXMLConverter - Error writing BPMN XML
org.activiti.bpmn.exceptions.XMLException: No converter for class found
   at org.activiti.bpmn.converter.BpmnXMLConverter.createXML(
   at org.activiti.bpmn.converter.BpmnXMLConverter.convertToXML(
   at org.activiti.bpmn.converter.BpmnXMLConverter.convertToXML(
   at org.activiti.engine.impl.repository.DeploymentBuilderImpl.addBpmnModel(
   at com.navarsete.stand012.DynamicActivitiProcessTestWithSpring.testMyJavaServiceTask(

…and really don't understand why. The only thing I've done is to extend the ServiceTask class, calling the constructor of the super class and then populating some properties. I haven't added, modified or removed any fields, so why is a (new?) converter needed? And what kind of converter?

I would appreciate some help on this one since I'm new to Activiti :)

Best regards,