Class not found exception for Execution Listener

I have created below process to send email notification when usertask reaches nearby its due date,

BpmnModelInstance modelInstance = Bpmn.createProcess()
.name(“SLA Demo”)
.id(“slaDemo”)
.executable()
.startEvent()
.name(“Start”)
.userTask()
.id(“approverOrder”)
.name(“Approve Order”)
.camundaAssignee(“demo”)
.camundaDueDate(“2017-03-02T18:30:00”)
.boundaryEvent()
.timerWithDate(“2017-03-02T18:00:00”)
.camundaExecutionListenerClass(“start”,“org.bpm.camunda.TaskAssignmentListener.java”)
.endEvent()
.done();
I have also defined process application for the listener.
But,when execution of process reaches to listener, it throws class not found exception.
Did I made any mistake?

Strip the .java from the class name.

Cheers,
Thorben

1 Like

Also, if you build the process via model API, you can set the listener like camundaExecutionListenerClass("start",TaskAssignmentListener.getClass().getName()). Then you will notice during compilation if the class does not exist.

Thanks for your quick response.
With first approach i am getting same error.

And for the second approach, i tried with below code, as getClass() was not working

camundaExecutionListenerClass(“start”,TaskAssignmentListener.class.getName())

But still getting same error.

Okay, please provide a unit test on github that reproduces your problem. You can use the unit testing template to get started. If you can’t provide a unit test, please provide the (simplified) sources of your application on github.

Thanks,
Thorben

Hi Thorben,
Thanks for your reply, appreciate your attentiveness.

Can i use connector through model API to get this email thing working, if not, could you please suggest any alternative for the same.

Thanks,
Anjum

Hi Anjum,

Connectors cannot be used as listeners. The approach to use an execution listener is the right one. I actually think there is not much that needs to be changed to make this work. However, I need to see an executable example to help spot the problem.

Cheers,
Thorben

Hi Throben,
I have added simplified code on github,
https://github.com/anjumaara3390/email-notification.git

Thanks,
Anjum

Hi Anjum,

The repository appears empty. Could you check that?

Cheers,
Thorben

Hi Thorben,
Sorry for inconvenience, I was facing some firewall issue while uploading files.
Please look at this https://github.com/anjumaara3390/AnjumGitHub

Thanks,
Anjum

Hi Anjum,

Thanks for sharing. When you create the model instance, you have the line

.camundaExecutionListenerClass("start","com.techm.camunda.TaskAssignmentListener")

However, the class name in your project is org.bpm.camunda.TaskAssignmentListener. Does it work if you change that?

Cheers,
Thorben

I have specified the correct class name but,
i missed to change class name while simplifying the code.

Does this mean this problem is resolved? If not, please update the repository.

Hi Thorben,
I have updated the repository.
Please check it.

Hi Anjum,

I assume you are deploying this application to a container with a shared process engine (for example Tomcat as can be downloaded from camunda.org). In this case, should not make a programmatic deployment via repository service but use the managed deployment via process applications. During process application deployment, the engine takes notice of your applications classloader, such that it can resolve classes that reside in your application such as execution listener implementations. See the docs section on resources access for details.

To make a process application deployment, you could align your application with the application that is developed in the BPMN getting started guide. Note that your process application class can override the method #createDeployment in case you need to add resources programmatically.

I hope this helps.

Cheers,
Thorben