Accessing java class in a bpmn present outside of the war file

Hello,

I am getting an error while executing the following scenario.

  1. I have deployed a war file in camunda tomcat along with bpmn files inside the war file.
  2. I have deployed one more new process using REST api (http://localhost:8080/engine-rest/deployment/create) and in this process I am using a java class in a service task from the war file deployed earlier . I am getting the following error now while starting the process.

The process could not be started. :
Cannot instantiate process definition demo-process5:1:f1ebb719-051c-11e8-9b29-9cad97d34f79: ENGINE-09008 Exception while instantiating class ‘com.sp.demo.camunda_poc.ServiceTask1Delegate’: ENGINE-09017 Cannot load class ‘com.sp.demo.camunda_poc.ServiceTask1Delegate’: com.sp.demo.camunda_poc.ServiceTask1Delegate

Please help help here. Find below my Java Class present in the war file. My idea use to use the java classes present in the war file in other process definitions deployed dynamically using REST API.

package com.sp.demo.camunda_poc;

import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;

/**

@author
*/
public class ServiceTask1Delegate implements JavaDelegate {

@Override
public void execute(DelegateExecution arg0) throws Exception {
System.out.println(“In process1 service Task1”);
arg0.setVariable(“process1”, “Process Variable 1”);

}
}

Hi @priyank,

This topic has been discussed before on this forum. See for example this post:

Cheers,
Thorben

Thanks I got some info like below.

ManagementService#registerProcessApplication is not exposed to the REST API, as well as the other way to do it: RepositoryService# createDeployment(ProcessApplicationReference processApplication)

Is there any other way we can achieve this using REST API?

You can implement a custom REST API endpoint that does this. https://docs.camunda.org/manual/7.8/reference/rest/overview/embeddability/ gives some pointers how to embed and extend the REST API. https://github.com/camunda/camunda-bpm-examples/tree/master/deployment/embedded-spring-rest is an example application that does this.

Thanks @thorben . I have checked this.
I am still getting below error.

{
“type”: “RestException”,
“message”: “Cannot instantiate process definition demo-process5:1:10: ENGINE-09008 Exception while instantiating class ‘com.sp.demo.camunda_poc.ServiceTask4Delegate’: ENGINE-09017 Cannot load class ‘com.sp.demo.camunda_poc.ServiceTask4Delegate’: com.sp.demo.camunda_poc.ServiceTask4Delegate”
}

“ServiceTask4Delegate” class is alreday present in the war file I have deployed. But when I deploy a new process using the REST API process is not able to find that class it seems. My bpmn file is not in the war file.
Can you please suggest me in which direction I should look to solve this issue in the best possible way?

@priyank How exactly did you solve this, I am trying to achieve the same?