# Process Instance with null Process Definition Key

**URL:** <https://forum.flowable.org/t/process-instance-with-null-process-definition-key/8453>\
**Category:** Flowable Engine\
**Created:** [September 24, 2021, 10:09am UTC](https://forum.flowable.org/t/process-instance-with-null-process-definition-key/8453 "2021-09-24T10:09:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![VasilTsimashchuk](https://avatars.discourse-cdn.com/v4/letter/v/ed655f/32.png) [@VasilTsimashchuk](https://forum.flowable.org/u/VasilTsimashchuk)\
**Post date:** [September 24, 2021, 10:09am UTC](https://forum.flowable.org/t/process-instance-with-null-process-definition-key/8453/1 "2021-09-24T10:09:21Z")

</div>

Dear Flowable experts,

we have observed the following behavior in our application. In a `JavaDelegate` extension and in Flowable Event Listeners we have, we query for the process instance of interest with the following query (or equivalent):

```auto
ProcessInstance processInstance = processEngineConfiguration.getRuntimeService().createProcessInstanceQuery()
                .processInstanceId(execution.getProcessInstanceId()).singleResult();

```

For some occasions, the `ProcessInstance` object returned contains a proper `processDefinitionKey`, for the others - not. As we need the `processDefinitionKey` in our scenario, we are forced to make an additional `ProcessDefinitionQuery`.

Is it an expected behavior that the `processDefinitionKey` of a `ProcessInstance` is not always in place? If yes, could you maybe give some guidance on when we could expect it and when not?

Thank you!

Best regards,  
Vasil

---

<div class="post-metadata">

**Author:** ![donkon](https://avatars.discourse-cdn.com/v4/letter/d/f475e1/32.png) [@donkon](https://forum.flowable.org/u/donkon)\
**Post date:** [March 15, 2022, 1:10pm UTC](https://forum.flowable.org/t/process-instance-with-null-process-definition-key/8453/2 "2022-03-15T13:10:04Z")

</div>

We have the same issue, not glad to see this problem unanswered

---

<div class="post-metadata">

**Author:** ![VasilTsimashchuk](https://avatars.discourse-cdn.com/v4/letter/v/ed655f/32.png) [@VasilTsimashchuk](https://forum.flowable.org/u/VasilTsimashchuk)\
**Post date:** [March 18, 2022, 8:47am UTC](https://forum.flowable.org/t/process-instance-with-null-process-definition-key/8453/3 "2022-03-18T08:47:08Z")

</div>

Hi @donkon,  
Unfortunately, we haven’t found the root cause for the problem and stayed with the approach where additional query is made.  
Best,  
Vasil

---

<div class="post-metadata">

**Author:** ![martin.grofcik](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/martin.grofcik/32/71_2.png) [@martin.grofcik](https://forum.flowable.org/u/martin.grofcik)\
**Post date:** [March 18, 2022, 11:16am UTC](https://forum.flowable.org/t/process-instance-with-null-process-definition-key/8453/4 "2022-03-18T11:16:47Z")

</div>

Hi Vasil,

> [@VasilTsimashchuk](#):
>
> Is it an expected behavior that the `processDefinitionKey` of a `ProcessInstance` is not always in place?

yes

> [@VasilTsimashchuk](#):
>
> If yes, could you maybe give some guidance on when we could expect it and when not?

All db operations are made before transaction is committed. (Operations are optimized too). That’s why db query returns null `processInstance` your code is invoked between `startEvent` and the first wait state. Up to date processInstance can be accessed from execution in java delegate, without db query

Regards  
Martin
