# Exception while trying to completeActivity exceptionally

**URL:** <https://community.temporal.io/t/exception-while-trying-to-completeactivity-exceptionally/590>\
**Category:** Community Support\
**Created:** [September 8, 2020, 6:25pm UTC](https://community.temporal.io/t/exception-while-trying-to-completeactivity-exceptionally/590 "2020-09-08T18:25:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![saket\_kothari](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/saket_kothari/32/53_2.png) [@saket\_kothari](https://community.temporal.io/u/saket_kothari)\
**Post date:** [September 8, 2020, 6:25pm UTC](https://community.temporal.io/t/exception-while-trying-to-completeactivity-exceptionally/590/1 "2020-09-08T18:25:44Z")

</div>

I am trying to complete activity exceptionally.  
Below is my code snippet-

```java
    WorkflowClient workflowClient = WorkflowClient.newInstance(host, port, DOMAIN);

                ActivityCompletionClient completionClient = workflowClient.newActivityCompletionClient();
                WorkflowExecution workflowExecution = new WorkflowExecution();
                workflowExecution.setRunId(graphiteQueryWrapper.getWorkflowMetadata().getRunId());
                workflowExecution.setWorkflowId(graphiteQueryWrapper.getWorkflowMetadata().getWorkflowId());
                try {
                    completionClient.completeExceptionally(workflowExecution, graphiteQueryWrapper.getWorkflowMetadata().getActivityId(),ex);
                } catch (ActivityCompletionException e) {
                    logger.error("Error completing storeMetrics activity" + e.getMessage());
                    e.printStackTrace();
                }

```

However, I am getting exception while closing activity exceptionally.

```auto
    com.uber.cadence.client.ActivityCompletionFailureException: ActivityId28
    	at com.uber.cadence.internal.external.ManualActivityCompletionClientImpl.fail(ManualActivityCompletionClientImpl.java:162)
    	at com.uber.cadence.internal.sync.ActivityCompletionClientImpl.completeExceptionally(ActivityCompletionClientImpl.java:52)
    	at com.ea.reporter.workers.graphite.GraphiteWorkflowImpl.storeGraphiteMetrics(GraphiteWorkflowImpl.java:50)
    	at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at com.uber.cadence.internal.sync.POJOWorkflowImplementationFactory$POJOWorkflowImplementation.execute(POJOWorkflowImplementationFactory.java:244)
    	at com.uber.cadence.internal.sync.WorkflowRunnable.run(WorkflowRunnable.java:47)
    	at com.uber.cadence.internal.sync.CancellationScopeImpl.run(CancellationScopeImpl.java:102)
    	at com.uber.cadence.internal.sync.WorkflowThreadImpl$RunnableWrapper.run(WorkflowThreadImpl.java:99)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    	at java.lang.Thread.run(Thread.java:748)
    Caused by: BadRequestError(message:ActivityID is not set on request.)
    	at com.uber.cadence.WorkflowService$RespondActivityTaskFailedByID_result$RespondActivityTaskFailedByID_resultStandardScheme.read(WorkflowService.java:28913)
    	at com.uber.cadence.WorkflowService$RespondActivityTaskFailedByID_result$RespondActivityTaskFailedByID_resultStandardScheme.read(WorkflowService.java:28899)
    	at com.uber.cadence.WorkflowService$RespondActivityTaskFailedByID_result.read(WorkflowService.java:28809)

```

Can someone please help?

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [September 8, 2020, 6:28pm UTC](https://community.temporal.io/t/exception-while-trying-to-completeactivity-exceptionally/590/2 "2020-09-08T18:28:38Z")

</div>

The root cause is “message:ActivityID is not set on request”. It looks like you are passing an empty ID to the `completeExceptinally `call.

---

<div class="post-metadata">

**Author:** ![saket\_kothari](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/saket_kothari/32/53_2.png) [@saket\_kothari](https://community.temporal.io/u/saket_kothari)\
**Post date:** [September 8, 2020, 6:33pm UTC](https://community.temporal.io/t/exception-while-trying-to-completeactivity-exceptionally/590/3 "2020-09-08T18:33:38Z")

</div>

Hi Maxim,  
com.uber.cadence.client.ActivityCompletionFailureException: ActivityId28  
I am trying to print ex.getMessage() and it is printing appropriate activity id as seen in the above trace.  
Is there anything else I am missing?

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [September 8, 2020, 6:56pm UTC](https://community.temporal.io/t/exception-while-trying-to-completeactivity-exceptionally/590/4 "2020-09-08T18:56:14Z")

</div>

Try reproducing it using [this Cadence sample](https://github.com/uber/cadence-java-samples/blob/master/src/main/java/com/uber/cadence/samples/hello/HelloAsyncActivityCompletion.java). If reproducible file an issue.

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [September 8, 2020, 7:03pm UTC](https://community.temporal.io/t/exception-while-trying-to-completeactivity-exceptionally/590/5 "2020-09-08T19:03:37Z")

</div>

I changed the similar temporal sample to use complete and complete exceptionally by Id and it worked fine.

---

<div class="post-metadata">

**Author:** ![saket\_kothari](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/saket_kothari/32/53_2.png) [@saket\_kothari](https://community.temporal.io/u/saket_kothari)\
**Post date:** [September 8, 2020, 7:11pm UTC](https://community.temporal.io/t/exception-while-trying-to-completeactivity-exceptionally/590/6 "2020-09-08T19:11:09Z")

</div>

okay thanks Maxim…I checked in cadence and it is failing.  
I will file an issue on the github repo.  
Thanks for the help.
