I am trying to deploy and run a workflow dynamically using REST APIs.
To Deploy , i use this API call:
which is successful and gives response as expected.
After deployment, on the cockpit I am able to see the workflow, with a red cross mark (which i believe means its deployed but not started yet)
Now to Start, I use this API call:
This call gives below 500 error:
"message": "Cannot instantiate process definition Process_1525247306711:2:3d87afa0-7935-11e8-85fe-0242ac11000b: ENGINE-09008 Exception while instantiating class 'com.delegates.ListenerDelegate': ENGINE-09017 Cannot load class 'com.delegates.ListenerDelegate': com.delegates.ListenerDelegate"
My workflow consists of service tasks with delegates attached. com.delegates.ListenerDelegate is the delegate class attached to the first state that needs to run.
the same exception happens when trying to start the process from the Camunda UI.
Please help me fix this issue.
Can up upload your process model?
How have you deployed the Java Classes that you’re calling in the model?
yes, Java classes are deployed with the war file. In fact, if I upload a bpmn with the war, it gets deployed and runs automatically, which means it is able to find the classes. Only when i try to deploy and run on the fly using rest api, it fails.
So you first deployed the process by deploying the war file and then you change the model and re-deploy the model via the rest API?
First - what exactly do you change in your model between the 2 deployments?
Second - This is not a very good idea in general, if you deploy your process via War you should continue to do so, if you restart the server it’ll probably re-deploy the war and perhaps cause issues. Is there a reason why you want to deploy via rest now?
My need is to deploy on the fly. I am not supposed to deploy the bpmn with the war file. I did this only to check if this way of deployment is working.
Even if I delete the bpmn from the war, restart Camunda engine, and then try to deploy and run the same bpmn on the fly, it fails and gives the same exception.
So as per your questions
First: nothing changes between two bpmns, its the same bpmn
Second: We do not want to restart server everytime we deploy a new bpmn. Hence, deployment through rest api is the only ask.
If you delete the war file you’re also deleting the java classes which would explain the error.
You can deploy a new WAR in run time without having to restart anything. It will just create a new version of the BPMN model or replace the java classes depending on what you’ve changed.
The only reason you might want to deploy a process from the modeler like that if you’re using external tasks and so do not have any dependent artifacts like java classes.
I am not deleting the war file. Only the bpmn.
My war has all the required classes. and this war is deployed in the engine.
I only want to deploy a new bpmn on the fly, not the war file.
“The only reason you might want to deploy a process from the modeler like that if you’re using external tasks and so do not have any dependent artifacts like java classes.”
so does this mean that bpmns having delegate classes cannot be deployed on the fly using the REST calls?
They can, but they shouldn’t. It’ll create inconsistencies. Let me explain:
If you deploy via a war file the next war file the bpmn model is maintained in camunda’s DB and the java classes AND BPMN model are stored in the war on the application server.
If you deploy via the REST API the bpmn model is kept in camunda’s DB without any dependency on the node itself.
Both of these work perfect well, both can be used for runtime deployment in the same. but if you mix them like you’ve been doing you’re going to cause serious issues.
e.g. if you have a war file deployed and then you directly deploy via the rest API, the model in the war file will be different to the one in the camunda DB and so if for some reason you start your server it’ll notice that the model in t he war file if different to the one deployed and try to re-deploy it.
So there is no reason why you should need to use the REST API to deploy processes if you rely on dependent java classes. Always deploy using the WAR.
I understand what you just said.
Just to be clear. I am not trying to mix both ways. Deployment through war is not our need. We only need deployment through REST. But even that doesn’t work and gives the above mentioned exception.
Project’s requirement is that users will create bpmns according to their needs. and deploy.
So if the way I am doing causes inconsistencies (i.e packaging the classes with war files and then trying to access the classes later with a new bpmn deployed on the fly), is there any way to register the classes on the fly too? (without redeploying the war file/restarting the server).
Also, this link in the documentation https://docs.camunda.org/manual/7.9/reference/rest/deployment/post-deployment/
doesn’t specify any such limitations that the to-be-deployed bpmn shouldn’t have any classes.
It would really help us if you could suggest a way to accomplish dynamic deployment and starting of bpmns having classes.
Your best solution would be to use External Tasks with the java external task client instead of using java delegates.
thanks. I will give it a try.