Boolean expression cannot resolve identifier

My gateway refuses to work , I am watching 2 - Camunda Tutorial for Java Developers on Vimeo

Where he set his gateway expression using the modeler to #{not weather} and #{weather} but with me it fails to resolve the variable

Here is my code which is identical to the one used in the video
public class CheckWeatherDelegate implements JavaDelegate {

@Override
public void execute(DelegateExecution execution) throws Exception {

	Random rando =new Random();
	execution.setVariable("name","Niall");
	execution.setVariable("weather", rando.nextBoolean());	
}

}

But it fails, I then tried changing the expression to the following below but nothing workds
${!weather} and {weather}
${not weather} and {weather}
#{not weather} and #{weather}

Where and how should I set the variables, I though you only set them using execution.setVariable(“weather”, rando.nextBoolean()); and set the expression in bpmn using the modeler to #{not weather} and #{weather} , I do not know where else I must define the variable like.

The error
The process could not be started. :
Cannot instantiate process definition SimpleDemo:1:9e2fac46-6de6-11e8-9ad2-402cf4108c7d: Unknown property used in expression: ${weather}. Cause: Cannot resolve identifier ‘weather’

image

1 Like

At a glance it seems ok, can you upload the BPMN file itself?

Hi @gra,

the process state is stored to the database only when a transaction is ended.
A transaction is ended when a wait state is reached (https://docs.camunda.org/manual/latest/user-guide/process-engine/transactions-in-processes/#wait-states) or using asynchronous continuations.

In your above model, the evaluation of the condition is reached in the same transaction started the process as there are no wait states before. which means your variables haven’t been stored to the database yet.

Please set asyncAfter attribute of “Check weather” service task to true. as below

camunda:asyncAfter="true"

This way, asynchronous continuations will break the execution flow (end the transaction) & your variables will be stored before execution reaches the gateway.

https://docs.camunda.org/manual/latest/user-guide/process-engine/transactions-in-processes/#understand-asynchronous-continuations

1 Like

It should still work without a commit before, it isn’t required that a variable needs to reach the database before it can be evaluated.

2 Likes

@hassang2h I set the asyncAfter attribute of “Check weather” to true but I still get the error, I attached the BPMN with the settings here

@ Nial I attached it the BPMN here I followed the video steps 2 - Camunda Tutorial for Java Developers on Vimeo but its not working for me. Another thing I also wanted to ensure is #{not weather} and #{weather} the correct expression or did I also mix the expression up because this is how it is done in the video?

When I start the process in Camunda engine I still get the error
The process could not be started. :
Cannot instantiate process definition SimpleDemo:1:52646dd7-6e37-11e8-b96b-402cf4108c7d: Unknown property used in expression: #{weather}. Cause: Cannot resolve identifier ‘weather’

Please find the BPMN attahed

process.bpmn (5.4 KB)

Looks like there is a very annoying little problem with the way you’ve connected up the symbols.

If you move the sequence flow which is going from the service task to the gateway you’ll notice that it’s not connected in the way in which it seems:

You need to delete the flow and create a new one going from check weather to the is weather ok gateway

3 Likes

Neill, this is just because you have dropped in the service activity box by dragging and dropping. and in your case its sits very well and the connectors adjusts automatically. But its not for all who follows your tutorials. Hence this.

I gone through the same problem… but its a problems and errors make us learning more…

Just wanted to let you know… to take care to mention this in your tutorials.

I think it’s more of a UX problem - and i think there are plans to mark overlapping sequence flows red so that people will be able to spot this problems faster.

1 Like