ENGINE 03051 - TaskListener Exception

Getting this error while starting a process instance: ENGINE-03051 There was an exception while invoking the TaskListener. Message: ‘com.camunda.demo.SimpleDemo.CamundaBpmProcessApplication doesn’t implement interface org.camunda.bpm.engine.delegate.TaskListener’ [ start-instance-error ]

@SajawalSajjad could you upload your bpmn file and this class com.camunda.demo.SimpleDemo.CamundaBpmProcessApplication?

process.bpmn (8.2 KB)

package com.camunda.demo.SimpleDemo;

import java.util.logging.Level;
import java.util.logging.Logger;

import org.camunda.bpm.application.ProcessApplication;
import org.camunda.bpm.application.impl.ServletProcessApplication;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.DelegateTask;
import org.camunda.bpm.engine.delegate.ExecutionListener;
import org.camunda.bpm.engine.delegate.TaskListener;

import jdk.jfr.internal.LogLevel;

/**

  • Process Application exposing this application’s resources to the process

  • engine.
    */
    @ProcessApplication
    public class CamundaBpmProcessApplication extends ServletProcessApplication {

    public TaskListener getTaskListener() {
    return new TaskListener() {

     	public Logger LOGGER = Logger.getLogger(CamundaBpmProcessApplication.class.getName());
    
     	public void notify(DelegateTask delegateTask) {
     		// handle all Task Events from Invoice Process
     		LOGGER.log(Level.INFO, String.format("Process definition ID: %s", delegateTask.getProcessInstanceId()));
     		
     	}
     };
    

    }

    public ExecutionListener getExecutionListener() {
    return new ExecutionListener() {
    public void notify(DelegateExecution execution) throws Exception {
    // handle all Execution Events from Invoice Process
    }
    };

    }
    }

@SajawalSajjad Do you use spring framework? Problem in your bpmn is you’ve configured the process application bootstrapping class itself as Task Listener which is not implementing TaskListener interface.

If you’re not using spring framework, then:

You should move the above task listener anonymous function code into separate class which should implement TaskListener interface and that class can be configured in the activity.

@ProcessApplication
public class CamundaBpmProcessApplication extends ServletProcessApplication {
    //can have lifecycle hooks
}

public class ExecutionListener implements ExecutionListener {
    public void notify(DelegateExecution execution) throws Exception {
      // handle all Execution Events from Invoice Process
    }
 }

public class LoggingTaskListener implements TaskListener {
  
  public Logger LOGGER = Logger.getLogger(LoggingTaskListener.class.getName());
  
  public void notify(DelegateTask delegateTask) {
    // handle all Task Events from Invoice Process
    LOGGER.log(Level.INFO, String.format("Process definition ID: %s", delegateTask.getProcessInstanceId()));
  }
}

In your bpmn file configure fully qualified path of this class <fully_qualified_path>\LoggingTaskListener as TaskListener instead of com.camunda.demo.SimpleDemo.CamundaBpmProcessApplication



If you use spring boot, then:

@Slf4j
@SpringBootApplication
@EnableProcessApplication
public class CamundaEnterpriseApplication {

	public static void main(String[] args) {
		SpringApplication.run(CamundaEnterpriseApplication.class, args);
	}

	@Bean("loggingListener")
	public TaskListener getTaskListener() {
		return new TaskListener() {
			@Override
			public void notify(DelegateTask delegateTask) {
				log.info("Executing logging task listener for activity: {}", delegateTask.getName());
			}
		};
	}

}

And listener config for user task will be like:

<bpmn:userTask id="CheckTaskListenerExecutionTask" name="Check TaskListener Execution">
      <bpmn:extensionElements>
        <camunda:taskListener delegateExpression="${loggingListener}" event="create" />
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_1esl66j</bpmn:incoming>
      <bpmn:outgoing>Flow_0i578ko</bpmn:outgoing>
</bpmn:userTask>

Now I provided the fully qualified path of the class below (CheckInspection):

package com.camunda.demo.SimpleDemo;
import org.camunda.bpm.engine.delegate.DelegateTask;
import org.camunda.bpm.engine.delegate.TaskListener;

public class CheckInspection implements TaskListener {

@Override
public void notify(DelegateTask delegateTask) {
	// TODO Auto-generated method stub

}

}

I get the following error: ENGINE-03051 There was an exception while invoking the TaskListener. Message: ‘ENGINE-09008 Exception while instantiating class ‘com.camunda.demo.SimpleDemo.CheckInspection’: ENGINE-09017 Cannot load class ‘com.camunda.demo.SimpleDemo.CheckInspection’: com.camunda.demo.SimpleDemo.CheckInspection’ [ start-instance-error ]

Note: I am not using spring boot