# Caused by: java.lang.IllegalArgumentException: No worker for taskQueue

**URL:** <https://community.temporal.io/t/caused-by-java-lang-illegalargumentexception-no-worker-for-taskqueue/13107>\
**Category:** Community Support\
**Tags:** java-sdk, general-impl\
**Created:** [August 8, 2024, 10:40am UTC](https://community.temporal.io/t/caused-by-java-lang-illegalargumentexception-no-worker-for-taskqueue/13107 "2024-08-08T10:40:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jxwang](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/jxwang/32/4270_2.png) [@jxwang](https://community.temporal.io/u/jxwang)\
**Post date:** [August 8, 2024, 10:40am UTC](https://community.temporal.io/t/caused-by-java-lang-illegalargumentexception-no-worker-for-taskqueue/13107/1 "2024-08-08T10:40:48Z")

</div>

Hi temporal,

I was running worker in one instance and it says:  
_13:16:00.827 [main] INFO i.t.s.b.a.template.WorkersTemplate - Creating configured worker for a task queue ACT-TXN-TASK-QUEUE_  
_13:16:00.864 [main] INFO i.t.s.b.a.template.WorkersTemplate - Registering auto-discovered workflow class class helloworldapp.versioning\_strategy.workflow.impl.ClientTxnWorkflowImpl on a worker ‘transactionWorker’ with a task queue ‘WORK-TXN-TASK-QUEUE’_

I was trying to get the worker in another instance  
_@Autowired_  
_WorkflowClient workflowClient;_

\*//My method: \*  
_WorkerFactory factory = WorkerFactory.newInstance(workflowClient);_  
_factory.getWorker(“ACT-TXN-TASK-QUEUE”).suspendPolling();_

This workflowClient can be autowired successfully, but getWorker throws exception: Caused by: java.lang.IllegalArgumentException: No worker for taskQueue. May i know how should I properly get worker?

Best regards,  
Jx

---

<div class="post-metadata">

**Author:** ![antonio.perez](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/antonio.perez/32/2417_2.png) [@antonio.perez](https://community.temporal.io/u/antonio.perez)\
**Post date:** [August 8, 2024, 12:47pm UTC](https://community.temporal.io/t/caused-by-java-lang-illegalargumentexception-no-worker-for-taskqueue/13107/2 "2024-08-08T12:47:02Z")

</div>

Hi @jxwang

I guess `WorkerFactory.newInstance` returns a different instance from the one used to create the workers.

Could you try injecting the workerFactory directly?

> @Autowired WorkerFactory workerFactory;

Antonio

---

<div class="post-metadata">

**Author:** ![jxwang](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/jxwang/32/4270_2.png) [@jxwang](https://community.temporal.io/u/jxwang)\
**Post date:** [August 13, 2024, 6:48am UTC](https://community.temporal.io/t/caused-by-java-lang-illegalargumentexception-no-worker-for-taskqueue/13107/3 "2024-08-13T06:48:39Z")

</div>

Hi Antonio,

Our worker is running in one micro service. The Stop command will be triggering from another service controlled by ops team.  
So in ops service this will be the config, the start workers will be set to false and no worker will be registered there.  
spring:  
application:  
name: application  
temporal:  
connection:  
target: 127.0.0.1:7233  
namespace: default  
start-workers: false  
So it failed to autowire worker factory.  
Any solution to stop a particular worker from another service?

Best regards,  
Jx

---

<div class="post-metadata">

**Author:** ![antonio.perez](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/antonio.perez/32/2417_2.png) [@antonio.perez](https://community.temporal.io/u/antonio.perez)\
**Post date:** [August 13, 2024, 1:18pm UTC](https://community.temporal.io/t/caused-by-java-lang-illegalargumentexception-no-worker-for-taskqueue/13107/4 "2024-08-13T13:18:36Z")

</div>

Hi @jxwang

> Any solution to stop a particular worker from another service?

Could you expose an endpoint in your worker service?

Antonio
