Problems with understanding "Unknown property used in expression" error

Hey guys,

I did the Advanced Java tutorial where Niall creates sub-process etc. Then I wanted to transfer it to my real project and run into problems.

I have a main process “Forschungsantrag” and a sub process “Pruefen”. The sub process is called after a user task in the main process. The sub process itself is a service task which is triggered by the expression "#{pruefenUnterlagen}. I tried to set the this variable trough my java class and set it to “true”.

That is my java code:

  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 {
	// TODO Auto-generated method stub
	
	Random rando = new Random();
	
	
	execution.setVariable("name", "demo");
	execution.setVariable("weatherOK", rando.nextBoolean());
	execution.setVariable("antragAbgelehnt", rando.nextBoolean());
}

}

Now if I start my process and I want to complete the first User task it says:

Cannot instantiate process definition Forschungsantrag:1:d82cd2ee-16d6-11ea-9f0f-0242ac110002: Unknown property used in expression: #{not antragAbgelehnt}. Cause: Cannot resolve identifier ‘antragAbgelehnt’

I assume the problem is, that I didn’t hand over the variable “antragAbgelehnt”, but the gateways in the process need this variable.

In general I don’t know exactly why the error above occurs and how I can handle it. Any help would be great :slight_smile: Attached you can although find the main process (process.bpmn) and the sub process (pruefen.bpmn)

Thank you and I wish you a good night! :slight_smile:

Pruefen.bpmn (2.2 KB) process.bpmn (12.6 KB)

So is the process able to get past the first gateway without any problems?
The second gateway is causing the problem them?

1 Like

Thanks for your reply Niall!

I had one major error, I did not set the variable “antragAbgelehnt” in my Java code, therefore I couldn’t execute the process. I fixed that.

Know my Java code looks like that:

public void execute(DelegateExecution execution) throws Exception {
	// TODO Auto-generated method stub
			
	
	execution.setVariable("name", "Matthias");
	execution.setVariable("pruefenUnterlagen", true);
	execution.setVariable("antragAbgelehnt", true);
}

If I execute my process it pauses at the first User-Task " Unterlagen an Personal und Org anisation weiterleiten" if I want to complete it, I get the following error:

Cannot submit task form 98e649a4-11f5-11ea-898a-0242ac110002: No initial activity found for subprocess Task_0hpsuhd: initialActivity is null

This isn’t a user task, in the model you uploaded this is the task which runs a java class so the process wouldn’t wait here.

I changed it to a user task and then I get this error…

Blockquote
Cannot submit task form a51b0f4c-1739-11ea-908a-0242ac110002: Unknown property used in expression: #{not antragAbgelehnt}. Cause: Cannot resolve identifier ‘antragAbgelehnt’

I see, so the error is basically explaining that a variable that is expected does not exist.
Once you changed the service task to the user task you removed the code that created the variable which is what is causing the problem.

1 Like

Cool, thanks! How can I assign a Java class to a User-Task?

You would need to add it as an execution listener.
Which would run either before or after your user task.