# Query DeploymentEntity throw NullPointerException

**URL:** <https://forum.flowable.org/t/query-deploymententity-throw-nullpointerexception/1164>\
**Category:** Flowable Engine\
**Created:** [November 8, 2017, 7:37am UTC](https://forum.flowable.org/t/query-deploymententity-throw-nullpointerexception/1164 "2017-11-08T07:37:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhiyin](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/zhiyin/32/376_2.png) [@zhiyin](https://forum.flowable.org/u/zhiyin)\
**Post date:** [November 8, 2017, 7:37am UTC](https://forum.flowable.org/t/query-deploymententity-throw-nullpointerexception/1164/1 "2017-11-08T07:37:52Z")

</div>

hi:  
When my code runs to ：

```
 ProcessDefinition pde = org.flowable.engine.impl.util.ProcessDefinitionUtil.getProcessDefinition(task.getProcessDefinitionId());

 or

 DeploymentEntity deploymentEntity = org.flowable.engine.impl.util.CommandContextUtil.getProcessEngineConfiguration()
            .getDeploymentEntityManager().findById(processDefinitionEntity.getDeploymentId());

```

Always throw NullPointerException exceptions ，why？ These Util tool classes is not supported like that？

then i Modify code like this：

DeploymentEntityManager dem = processEngineConfiguration.getDeploymentEntityManager();  
DeploymentEntity deployment = dem.findById(pde.getDeploymentId());

Still throw an exception，in debug mode ，i find in class Context.class method getCommandContext() is null！  
please How do I operate it?

Best regards  
zhiyin

---

<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:** [November 8, 2017, 8:26am UTC](https://forum.flowable.org/t/query-deploymententity-throw-nullpointerexception/1164/2 "2017-11-08T08:26:39Z")

</div>

Hi Zhiyin,

manager’s findById can be used only in the command context (see usages).  
Use repository service to query for deployments by id.

Regards  
Martin

---

<div class="post-metadata">

**Author:** ![zhiyin](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/zhiyin/32/376_2.png) [@zhiyin](https://forum.flowable.org/u/zhiyin)\
**Post date:** [November 8, 2017, 9:40am UTC](https://forum.flowable.org/t/query-deploymententity-throw-nullpointerexception/1164/3 "2017-11-08T09:40:32Z")

</div>

hi martin.grofcik，  
I found other ways to solve my problem. Thank you very much for your advice！

Best regards  
zhiyin
