# Can't run APM Java agent in Alfresco cluster environment

**URL:** <https://discuss.elastic.co/t/cant-run-apm-java-agent-in-alfresco-cluster-environment/172962>\
**Category:** APM\
**Created:** [March 19, 2019, 12:29pm UTC](https://discuss.elastic.co/t/cant-run-apm-java-agent-in-alfresco-cluster-environment/172962 "2019-03-19T12:29:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deny7](https://avatars.discourse-cdn.com/v4/letter/d/e0b2c6/32.png) [@Deny7](https://discuss.elastic.co/u/Deny7)\
**Post date:** [March 19, 2019, 12:29pm UTC](https://discuss.elastic.co/t/cant-run-apm-java-agent-in-alfresco-cluster-environment/172962/1 "2019-03-19T12:29:36Z")

</div>

Hi,

I'm running Alfresco development environment on two windows 2012 servers in cluster. I was able to configure filebeat, logstash, elastic, kibana for my logs.

Now I want to add APM server and APM Java agent for monitoring.

I did instalation according to elactic documentation, but when I start this server, It gives me this exception:

```
2019-03-19 09:50:16,848 ERROR [org.springframework.extensions.webscripts.AbstractRuntime] Exception from executeScript: java.io.NotSerializableException: co.elastic.apm.agent.impl.ContextInScopeRunnableWrapper
com.hazelcast.nio.HazelcastSerializationException: java.io.NotSerializableException: co.elastic.apm.agent.impl.ContextInScopeRunnableWrapper

```

I can't find this exception on google. I think it's related to that I'm running this server in cluster, because when I instaled agent on my other environment which is not running in cluster, It was working.

I added agent to both nodes of this cluster.

Can anybody help or point me at right direction?

**Kibana version:**  
**6.6.1**

**Elasticsearch version:**  
**6.6.1**

**APM Server version:**  
**6.6.2**

**APM Agent language and version:**  
**Java, 1.4.0**

---

<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:** [March 19, 2019, 1:06pm UTC](https://discuss.elastic.co/t/cant-run-apm-java-agent-in-alfresco-cluster-environment/172962/2 "2019-03-19T13:06:53Z")

</div>

Hi and thanks a lot for using the Java agent 🙂

I have a suspicion what could be the cause of this. Could you paste the full stack trace? That would help me to pinpoint the exact problem.

In the meantime, could you set this configuration:

```auto
classes_excluded_from_instrumentation=(?-i)org.infinispan*,(?-i)org.apache.xerces*,(?-i)org.jboss.as.*,(?-i)io.undertow.core*,(?-i)org.eclipse.jdt.ecj*,(?-i)org.wildfly.extension.*,(?-i)org.wildfly.security*,(?-i)com.hazelcast.*

```

I think the problem is that hazelcast offers `Executor` implementations which allow the submitted `Runnable` to be executed on another JVM. But that requires the `Runnable` to implement the `Serializable` interface. Because of the instrumentation we do, we wrap the `Runnable`s submitted to an `Executor` with a non-serializable `Runnable`.

The config setting will disable instrumentation for hazelcast, so it should work again.

Thanks for reporting this,  
Felix

---

<div class="post-metadata">

**Author:** ![Deny7](https://avatars.discourse-cdn.com/v4/letter/d/e0b2c6/32.png) [@Deny7](https://discuss.elastic.co/u/Deny7)\
**Post date:** [March 19, 2019, 1:55pm UTC](https://discuss.elastic.co/t/cant-run-apm-java-agent-in-alfresco-cluster-environment/172962/3 "2019-03-19T13:55:59Z")

</div>

Thank you very much for quick response. I Added your configuration and It's working. Thanks!!!!!

**Stacktrace:**

[https://justpaste.it/1ugkj](https://justpaste.it/1ugkj)

---

<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:** [March 19, 2019, 2:46pm UTC](https://discuss.elastic.co/t/cant-run-apm-java-agent-in-alfresco-cluster-environment/172962/4 "2019-03-19T14:46:40Z")

</div>

I have created a PR to exclude Hazelcast from the default instrumentation: [https://github.com/elastic/apm-agent-java/pull/536](https://github.com/elastic/apm-agent-java/pull/536)

---

<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:** [April 9, 2019, 10:51am UTC](https://discuss.elastic.co/t/cant-run-apm-java-agent-in-alfresco-cluster-environment/172962/5 "2019-04-09T10:51:09Z")

</div>

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