IdentityService.getCurrentAuthentication() is null after Timer Boundary Event

Hi all,

I have a process containing an user task on which an interrupting timer boundary event is attached to.

No matter if a timeout is triggered or not, later in the process flow, both “paths” will arrive to the same Service Task.

In the Java Delegate class of this service task I’m accessing the user id of the current authenticated user via:

ProcessEngines.getDefaultProcessEngine()
              .getIdentityService()
              .getCurrentAuthentication()
              .getUserId();

Now here is my issue:

  • In case the user task gets completed properly, I’m able to retrieve the user id.

  • But if the timeout is triggered on the user task the method getCurrentAuthentication returns null

I don’t get any logs related to this issue, just the service which requires the user id fails.

Best regards
Marvin

I get the same issue:

getCurrentAuthentication returns null

also if I declare a service task to be running asynchronously by checking the “Asynchronous Before”-Box in the Asynchronous Continuations section of the service task.

I was going through the following documentation to check if maybe my configuration of the JobExecutor is wrong/different from what is written there, but this is not the case :confused:

https://docs.camunda.org/manual/7.4/user-guide/process-engine/the-job-executor/
https://docs.camunda.org/manual/7.4/user-guide/process-engine/transactions-in-processes/

Does someone has an idea what the problem could be related to?

Hi @Marvin_Kehr,

may I ask what id you would be expecting if the boundary timer event is triggered?
The id of the user that started the process instance?
The id of the user the task was assigned to?
What if it hadn’t been assigned to any user yet?

The job executor is not related to any authenticated user, therefore the API call you use is not returning any value in case of timer execution or asynchronous continuation execution since both cases are executed by the job executor.

One option here is to store the id to a process variable when the user task is created with the help of a task listener. Whatever that id might be in your case (see questions above). In your service task you can than access this variable and retrieve the value you need no matter which path was taken.

Best,
Tobias

1 Like

Hi @tmetzke,

I would expect that the method getCurrentAuthentication().getUserId() returns the id of the user which completed the previous user task in the process.

But in the end, it works with your approach to store the id of the user to a process variable.

So many thanks for your help :slight_smile:

Best regards
Marvin