# APM Java agent - IndexOutOfBoundsException

**URL:** <https://discuss.elastic.co/t/apm-java-agent-indexoutofboundsexception/159419>\
**Category:** APM\
**Created:** [December 4, 2018, 8:28pm UTC](https://discuss.elastic.co/t/apm-java-agent-indexoutofboundsexception/159419 "2018-12-04T20:28:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Asaf\_Shabat](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/asaf_shabat/32/24442_2.png) [@Asaf\_Shabat](https://discuss.elastic.co/u/Asaf_Shabat)\
**Post date:** [December 4, 2018, 8:28pm UTC](https://discuss.elastic.co/t/apm-java-agent-indexoutofboundsexception/159419/1 "2018-12-04T20:28:14Z")

</div>

Hi,

I have Wildfly containers that recently got IndexOutOfBoundsException.  
I'm working with Java agent 1.0.1 and APM-Server 6.5.1

Can you help?

Stack trace attach:

[0m[31m12:25:47.699 ERROR [io.undertow.request] (default task-15) UT005023: Exception handling request to /api/households/5380009081/sync: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

at java.util.ArrayList.rangeCheck(ArrayList.java:657)

at java.util.ArrayList.get(ArrayList.java:433)

at co.elastic.apm.util.PotentiallyMultiValuedMap.add(PotentiallyMultiValuedMap.java:57)

at co.elastic.apm.impl.context.Response.addHeader(Response.java:64)

at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:52)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)

at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)

at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)

at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)

at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)

at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)

at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)

at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)

at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)

at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)

at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)

at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)

at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)

at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)

at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:284)

at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:263)

at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)

at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:174)

at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)

at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:793)

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)

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [December 5, 2018, 5:18am UTC](https://discuss.elastic.co/t/apm-java-agent-indexoutofboundsexception/159419/2 "2018-12-05T05:18:40Z")

</div>

Hi,

Thanks for letting us know, we will look into this. I opened an issue for it - [https://github.com/elastic/apm-agent-java/issues/371](https://github.com/elastic/apm-agent-java/issues/371), so any other information you can provide in addition will be better to add there.  
If I understand correctly, it sounds like you have it running and tested for some time and then got this once. Is it the case or is it consistently occurring with this request?  
The reason I ask is that if it is a sporadic thing, it sounds like a concurrency thing (and I can see how this can happen in our code due to concurrency issue). I see that the request has a `sync` in path, but worth the shot in this direction.  
In general, any information you can give us on how you use RESTEasy (or anything else) to serve the request can be very helpful. If you can share the code handling the related request that would be best.

Thanks,  
Eyal.

---

<div class="post-metadata">

**Author:** ![Asaf\_Shabat](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/asaf_shabat/32/24442_2.png) [@Asaf\_Shabat](https://discuss.elastic.co/u/Asaf_Shabat)\
**Post date:** [December 5, 2018, 7:01am UTC](https://discuss.elastic.co/t/apm-java-agent-indexoutofboundsexception/159419/3 "2018-12-05T07:01:14Z")

</div>

Hi Eyal,  
First, thank you for the quick response!

We've experienced it in the middle of LoadTesting phase.  
I'll check about the code sharing.. will let you know.

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:** [December 26, 2018, 3:01am UTC](https://discuss.elastic.co/t/apm-java-agent-indexoutofboundsexception/159419/4 "2018-12-26T03:01:29Z")

</div>

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