# Java APM Agent throws ClassNotFoundException in Wildfly

**URL:** <https://discuss.elastic.co/t/java-apm-agent-throws-classnotfoundexception-in-wildfly/158779>\
**Category:** APM\
**Created:** [November 29, 2018, 2:34pm UTC](https://discuss.elastic.co/t/java-apm-agent-throws-classnotfoundexception-in-wildfly/158779 "2018-11-29T14:34:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdindoffer](https://avatars.discourse-cdn.com/v4/letter/m/65b543/32.png) [@mdindoffer](https://discuss.elastic.co/u/mdindoffer)\
**Post date:** [November 29, 2018, 2:34pm UTC](https://discuss.elastic.co/t/java-apm-agent-throws-classnotfoundexception-in-wildfly/158779/1 "2018-11-29T14:34:36Z")

</div>

We are using the Java APM agent v1.1.0 for monitoring a webapp in Wildfly 9.0.2.FINAL running on OpenJDK 8.  
Everything works fine, until the the apm-agent-api is thrown into the mix. Whenever we access the ElasticApm class, it throws a ClassNotFoundException.  
I've created a tiny HelloWorld example for reproducing the exception on [github](https://github.com/mdindoffer/wildfly-apm-helloworld).

The Agent api is correctly included in the application war. However the api classes are simply not loaded.

 ![apm_api_classes](https://us1.discourse-cdn.com/elastic/original/3X/1/3/133f8d1d58a451989be1c5c5424ad5cbfee2f20f.png)

Things I've tried:

- Adding JBOSS\_MODULES\_SYSTEM\_PKGS="co.elastic.apm"
- Deploying the apm-agent-api as a global-module
- Deploying the example to newest Wildfly 14.0.2.FINAL

Nothing helps. APM logs [here](https://gist.github.com/mdindoffer/9ea54f40a07fd1e0a10be561affe905b)  
Stacktrace [here](https://gist.github.com/mdindoffer/b84c9a835acd5dd762f7639f362f827b)

Until this is solved I suggest adding a note to Wildfly in [Supported technologies](https://www.elastic.co/guide/en/apm/agent/java/current/supported-technologies-details.html).

---

<div class="post-metadata">

**Author:** ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)\
**Post date:** [November 29, 2018, 2:54pm UTC](https://discuss.elastic.co/t/java-apm-agent-throws-classnotfoundexception-in-wildfly/158779/2 "2018-11-29T14:54:43Z")

</div>

Hi,

it looks like the apm-agent-api jar did not make it into your `.war/WEB-INF/lib` could you verify that?

Cheers,  
Felix

---

<div class="post-metadata">

**Author:** ![mdindoffer](https://avatars.discourse-cdn.com/v4/letter/m/65b543/32.png) [@mdindoffer](https://discuss.elastic.co/u/mdindoffer)\
**Post date:** [November 29, 2018, 3:14pm UTC](https://discuss.elastic.co/t/java-apm-agent-throws-classnotfoundexception-in-wildfly/158779/3 "2018-11-29T15:14:08Z")

</div>

Hi,  
The apm-agent-api.jar is correctly included in the `.war/WEB-INF/lib` directory alongside other dependencies.

---

<div class="post-metadata">

**Author:** ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)\
**Post date:** [November 29, 2018, 4:31pm UTC](https://discuss.elastic.co/t/java-apm-agent-throws-classnotfoundexception-in-wildfly/158779/4 "2018-11-29T16:31:33Z")

</div>

I was able to reproduce this in this PR: [https://github.com/elastic/apm-agent-java/pull/361](https://github.com/elastic/apm-agent-java/pull/361)

I have the suspicion that this is related to the enabled bootdelegation for `co.elastic.apm.*`. That may make it so that these classes can only be loaded from the bootstrap class loader and not from the application class loader where the API module is at.

---

<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 20, 2018, 12:31pm UTC](https://discuss.elastic.co/t/java-apm-agent-throws-classnotfoundexception-in-wildfly/158779/5 "2018-12-20T12:31:51Z")

</div>

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