Boolean expression cannot resolve identifier


#1

My gateway refuses to work , I am watching https://vimeo.com/235728986

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


#2

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


#3

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


#4

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.


#5

@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 https://vimeo.com/235728986 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)


#6

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