# NoSuchElementException when SQS receiver throws an Exception

**URL:** <https://discuss.elastic.co/t/nosuchelementexception-when-sqs-receiver-throws-an-exception/322930>\
**Category:** APM\
**Tags:** java\
**Created:** [January 11, 2023, 1:16pm UTC](https://discuss.elastic.co/t/nosuchelementexception-when-sqs-receiver-throws-an-exception/322930 "2023-01-11T13:16:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cavarzan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cavarzan/32/115817_2.png) [@cavarzan](https://discuss.elastic.co/u/cavarzan)\
**Post date:** [January 11, 2023, 1:16pm UTC](https://discuss.elastic.co/t/nosuchelementexception-when-sqs-receiver-throws-an-exception/322930/1 "2023-01-11T13:16:52Z")

</div>

**APM Agent language and version** :

Java - 1.35.0

**Is there anything special in your setup?** For example, are you using the Logstash or Kafka outputs? Are you using a load balancer in front of the APM Servers? Have you changed index pattern, generated custom templates, changed agent configuration etc.  
NO

**Description of the problem including expected versus actual behavior. Please include screenshots (if relevant)**:

Error happens when an Exception is thrown when method called from an AWS SQS receiver

**Steps to reproduce** :

1. Receive a SQS message from AWS
2. Throw an Exception

**Errors in browser console (if relevant)**:

**Provide logs and/or server output (if relevant)**:

java.util.NoSuchElementException  
at java.base/java.util.ArrayDeque.removeFirst(Unknown Source)  
at java.base/java.util.ArrayDeque.remove(Unknown Source)  
at co.elastic.apm.agent.impl.ActiveStack.deactivate(ActiveStack.java:123)  
at co.elastic.apm.agent.impl.ElasticApmTracer.deactivate(ElasticApmTracer.java:771)  
at co.elastic.apm.agent.impl.transaction.AbstractSpan.deactivate(AbstractSpan.java:655)  
at co.elastic.apm.agent.concurrent.RunnableCallableForkJoinTaskInstrumentation$AdviceClass.onExit(RunnableCallableForkJoinTaskInstrumentation.java:80)  
at com.amazonaws.services.sqs.AmazonSQSAsyncClient$5.call(AmazonSQSAsyncClient.java:603)  
at com.amazonaws.services.sqs.AmazonSQSAsyncClient$5.call(AmazonSQSAsyncClient.java:586)  
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)  
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)  
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)  
at java.base/java.lang.Thread.run(Unknown Source)

---

<div class="post-metadata">

**Author:** ![Jack\_Shirazi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jack_shirazi/32/91641_2.png) [@Jack\_Shirazi](https://discuss.elastic.co/u/Jack_Shirazi)\
**Post date:** [January 11, 2023, 3:36pm UTC](https://discuss.elastic.co/t/nosuchelementexception-when-sqs-receiver-throws-an-exception/322930/2 "2023-01-11T15:36:11Z")

</div>

Thanks, I'm looking into this

---

<div class="post-metadata">

**Author:** ![Jack\_Shirazi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jack_shirazi/32/91641_2.png) [@Jack\_Shirazi](https://discuss.elastic.co/u/Jack_Shirazi)\
**Post date:** [January 11, 2023, 5:08pm UTC](https://discuss.elastic.co/t/nosuchelementexception-when-sqs-receiver-throws-an-exception/322930/3 "2023-01-11T17:08:08Z")

</div>

Please try with [this snapshot](https://apm-ci.elastic.co/job/apm-agent-java/job/apm-agent-java-mbp/job/PR-2960/1/artifact/src/github.com/elastic/apm-agent-java/elastic-apm-agent/target/elastic-apm-agent-1.35.1-SNAPSHOT.jar) ([PR](https://github.com/elastic/apm-agent-java/pull/2960)) - please try both with and without throwing the exception and check that you get the APM transaction displayed in the UI you expect in each situation (assuming there is a transaction here, if not please tell me that is not a relevant aspect). Thanks

---

<div class="post-metadata">

**Author:** ![cavarzan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cavarzan/32/115817_2.png) [@cavarzan](https://discuss.elastic.co/u/cavarzan)\
**Post date:** [January 11, 2023, 5:25pm UTC](https://discuss.elastic.co/t/nosuchelementexception-when-sqs-receiver-throws-an-exception/322930/4 "2023-01-11T17:25:28Z")

</div>

How fast Jack!

Great, I'll update the agent and update the topic soon.

Thanks

---

<div class="post-metadata">

**Author:** ![Jack\_Shirazi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jack_shirazi/32/91641_2.png) [@Jack\_Shirazi](https://discuss.elastic.co/u/Jack_Shirazi)\
**Post date:** [January 23, 2023, 2:38pm UTC](https://discuss.elastic.co/t/nosuchelementexception-when-sqs-receiver-throws-an-exception/322930/5 "2023-01-23T14:38:16Z")

</div>

Actually we have a higher level bug fix, so if you could try [this snapshot](https://apm-ci.elastic.co/job/apm-agent-java/job/apm-agent-java-mbp/job/PR-2979/3/artifact/src/github.com/elastic/apm-agent-java/elastic-apm-agent/target/) from [this PR](https://github.com/elastic/apm-agent-java/pull/2979), that would be better. Thanks

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 13, 2023, 10:38am UTC](https://discuss.elastic.co/t/nosuchelementexception-when-sqs-receiver-throws-an-exception/322930/6 "2023-02-13T10:38:23Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
