# RuntimeService returns null in JavaDelegate

**URL:** <https://forum.flowable.org/t/runtimeservice-returns-null-in-javadelegate/6862>\
**Category:** Flowable Engine\
**Created:** [October 3, 2020, 4:40pm UTC](https://forum.flowable.org/t/runtimeservice-returns-null-in-javadelegate/6862 "2020-10-03T16:40:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![suds](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@suds](https://forum.flowable.org/u/suds)\
**Post date:** [October 3, 2020, 4:40pm UTC](https://forum.flowable.org/t/runtimeservice-returns-null-in-javadelegate/6862/1 "2020-10-03T16:40:47Z")

</div>

Hi

Want to set the businessKey dynamically via JavaDelagate in service task. Delegate Java class is deployed as jar inside flowable-task.war. But when executing null pointer exception is thrown at this statement -\> runtimeService.updateBusinessKey

Flowable ver : 6.5.0.26

@Autowired  
private RuntimeService runtimeService;

---

<div class="post-metadata">

**Author:** ![filiphr](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/filiphr/32/315_2.png) [@filiphr](https://forum.flowable.org/u/filiphr)\
**Post date:** [October 7, 2020, 6:44am UTC](https://forum.flowable.org/t/runtimeservice-returns-null-in-javadelegate/6862/2 "2020-10-07T06:44:40Z")

</div>

Hey @suds,

Are you by any chance using `flowable:class` in your service task?

Have a look at [this](https://flowable.com/open-source/docs/bpmn/ch07b-BPMN-Constructs/#java-service-task) section of the documentation for more information about the different attributes that you can use for the service task.

The most important is that when you are using `flowable:class` then you can’t use Spring Autowiring in those classes, because Flowable will initialise them and not Spring.

If you want to use autowiring then you will have to make your JavaDelegate a Spring Component and use `flowable:delegateExpression`.

Cheers,  
Filip

---

<div class="post-metadata">

**Author:** ![suds](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@suds](https://forum.flowable.org/u/suds)\
**Post date:** [October 24, 2020, 7:01am UTC](https://forum.flowable.org/t/runtimeservice-returns-null-in-javadelegate/6862/3 "2020-10-24T07:01:36Z")

</div>

Thanks @filiphr.

Was indeed using java class, but yes in this scenario , bean creation required via delegateExpression
