The process could not be started. : Cannot instantiate process definition

Hi Team,

Iam getting below error when i try to start process.

The process could not be started. : Cannot instantiate process definition SimpleDemo:3:c5e1aaa8-21fb-11ea-b5c4-9cb6d0c2b847: Unknown property used in expression: #{cflag}. Cause: Cannot resolve identifier ‘cflag’

My java class is below process.bpmn (4.7 KB)

package com.camunda.demo.SimpleDemo;

import java.util.Random;

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

public class CheckWeatherDelegate implements JavaDelegate {

@Override
public void execute(DelegateExecution execution) throws Exception {
	
	Random random=new Random();
	
	
	execution.setVariable("cflag", random.nextBoolean());
	// TODO Auto-generated method stub

}

}

Can you please help me on this issue .

Regards
Ravi Babu.

Hi @RaviBabu,

The class attribute of the service task “check Weather” in your model is set to
org.camunda.bpm.engine.delegate.DelegateExecution

Where it should be set to
com.camunda.demo.SimpleDemo.CheckWeatherDelegate

1 Like

Hi ,

Thank you for looking into my error . I changed class attribute as com.camunda.demo.SimpleDemo.CheckWeatherDelegate** but still getting same error .process.bpmn (4.7 KB)

Hi @RaviBabu,

Try to set camunda:asyncAfter=“true” on Service Task

By default process state is only stored to the database when token reaches a wait state.
“A wait state is a task which is performed later , which means that the engine persists the current execution to the database and waits to be triggered again”.

https://docs.camunda.org/manual/latest/user-guide/process-engine/transactions-in-processes/#wait-states

And since service task is not a wait state then asynchronous Continuations can be used to add transaction boundaries.

https://docs.camunda.org/manual/latest/user-guide/process-engine/transactions-in-processes/#transaction-boundaries

I tried camunda:asyncAfter=“true” but still same issue.

process.bpmn (4.7 KB) .

Iam still facing the problem , Can any one please help me on this issue ?

@RaviBabu from your model service task element “Check Weather” is not connected to the exclusive gateway.

image

Try this bpmn file which i corrected it: process.bpmn (5.9 KB)

2 Likes

@aravindhrs

Thank you so much , it worked this time .

Hi Aravind,
I agree with the solution. But what should we do to connect to gateway. I mean what is the difference between two diagrams?
What do you mean by exclusive gateway?

@Naveen_Prasad, Gateways are used to control how the process flows.

image

  • An exclusive gateway evaluates the state of the business process and, based on the condition, breaks the flow into one of the two or more mutually exclusive paths.

  • Exclusive gateway is a diversion point of a business process flow.

  • A diverging Exclusive Gateway (Decision) is used to create alternative paths within a Process flow.

  • For a given instance of the process, there is only one of the paths can be taken.

  • In case multiple sequence flow have a condition that evaluates to ‘true’, the first one defined in the XML is exclusively selected for continuing the process.

  • A Decision can be thought of as a question that is asked at a particular point in the Process.

  • The question has a defined set of alternative answers.

  • Each answer is associated with a condition Expression that is associated with a Gateway’s outgoing Sequence Flows.

  • When dividing the flow, it directs the flow exactly to one of the output branches. Although it is common practice to converge, it is optional for the Exclusive gateway and according to Bruce Silver’s modeling style guide, should be avoided.

The suggested modeling of gateways is state the checking (question) in the gateway (diamond shape) and state the condition in the sequence flow. When the business process is executed (either by manual process or with automatic process), the condition will evaluate one by one and once the first condition is fulfilled, we still trigger the connected activity and stop evaluate other condition.

In the example below, an exclusive gateway requires that the mode of transportation be evaluated. In this case, one light will be placed in the Old North Church if the British attack by land, two if by sea.

image


Service Task is not connected with the gateway, instead gateway was directly connected from start event.

Solution:

  • Removed one of the outgoing sequence flow from start event to gateway.

  • Added sequence flow between service task and exclusive gateway.

Thanks Aravind.

Hi All,

I have similar issue but the exception is little different. Below is the exception and my Java class.

Exception :
The process could not be started. : camundajar/impl/scala/util/Random

Java Class :

package com.camunda.demo.SimpleDemo;

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

import camundajar.impl.scala.util.Random;

public class CheckWeatherDelegate implements JavaDelegate {

@Override
public void execute(DelegateExecution execution) throws Exception {
	
	Random rando = new Random();
	
	execution.setVariable("name", "Raghu");
	execution.setVariable("weatherOk", rando.nextBoolean());
}

}

@Raghu_1794 could you provide complete stack trace of your exception?

SimpleDemo_Stack Trace.txt (43.5 KB)
@aravindhrs Attached the Stacktrace from command prompt.

I can’t seem to find anything else on the net that does this import.
Try importing java.util.Random instead.

This can be seen in your stack trace as part of the problem:
java.lang.NoClassDefFoundError: camundajar/impl/scala/util/Random

The system can’t find a java class camundajar.impl.scala.util.Random to import, and so it fails out.

@Raghu_1794 change the import statement in CheckWeatherDelegate class from

import camundajar.impl.scala.util.Random;

to this

import java.util.Random;

@aravindhrs Thanks for your response. I have modified the import statement and created a new .war file. To redeploy it, I have deleted the existing war file from deployments folder and deleted the process from cockpit. Once I redeploy the war file, I couldn’t see the process in cockpit. I made sure that the process.bpmn is file available in “src/main/resources” path before generating the war file.
Could you lease guide me on this.
I even tried deploying the process.bmn directly from cockpit, but it is throwing exception “ENGINE-09008 Exception while instantiating class” while starting the process from tasklit.

@Raghu_1794 could you upload your bpmn file??

@aravindhrs I have created a new project with new name and completed the deployment. It’s been working fine now. Seems I have made mistakes throughout the project creation and deployment and corrected them while working on the new project. Your inputs helped me this time.

Thanks for your help.

Hello,

I am getting somewhat similar error when starting the process:

The process could not be started. : Cannot instantiate process definition loanApproval:4:e8b69f84-13c9-11ed-94d3-540ebb5ec30d: ENGINE-09008 Exception while instantiating class ‘org.camunda.bpm.getstarted.loanapproval.CheckWeather’: ENGINE-09017 Cannot load class ‘org.camunda.bpm.getstarted.loanapproval.CheckWeather’: org.camunda.bpm.getstarted.loanapproval.CheckWeather

My java class is below
loanApproval.bpmn (5.9 KB)
:

package org.camunda.bpm.getstarted.loanapproval;

import java.util.Random;

import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.springframework.stereotype.Component;

@Component("checkweather")
public class CheckWeather implements JavaDelegate {

	@Override
	public void execute(DelegateExecution execution) throws Exception {
		Random rndm = new Random();
		execution.setVariable("isWeatherOk", rndm.nextBoolean());
	}

}

@aravindhrs please help me in this issue.