# Attaching apm-agent-attach-cli.jar to a running process that already has javaagents

**URL:** <https://discuss.elastic.co/t/attaching-apm-agent-attach-cli-jar-to-a-running-process-that-already-has-javaagents/321595>\
**Category:** Elastic Observability\
**Created:** [December 19, 2022, 8:08pm UTC](https://discuss.elastic.co/t/attaching-apm-agent-attach-cli-jar-to-a-running-process-that-already-has-javaagents/321595 "2022-12-19T20:08:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yuri\_Bernstein](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuri_bernstein/32/114934_2.png) [@Yuri\_Bernstein](https://discuss.elastic.co/u/Yuri_Bernstein)\
**Post date:** [December 19, 2022, 8:08pm UTC](https://discuss.elastic.co/t/attaching-apm-agent-attach-cli-jar-to-a-running-process-that-already-has-javaagents/321595/1 "2022-12-19T20:08:44Z")

</div>

Hi,  
I am trying to attach an agent to a running process that has another agent attached at startup time using `-javaagent` option. The agent throws the following:

```auto
{"@timestamp":"2022-12-19T19:50:48.574Z","log.level": "INFO","message":"The agent is already attached to JVM 1 myapp", "ecs.version": "1.2.0","service.name":"java-attacher","event.dataset":"java-attacher.log","process.thread.name":"main","log.logger":"co.elastic.apm.attach.AgentAttacher"}
{"@timestamp":"2022-12-19T19:50:48.574Z","log.level":"ERROR","message":"Unable to attach to JVM with PID = 1", "ecs.version": "1.2.0","service.name":"java-attacher","event.dataset":"java-attacher.log","process.thread.name":"main","log.logger":"co.elastic.apm.attach.AgentAttacher"}

```

Any advise on how to overcome this will be highly appreciated

Running in a container where PID 1 is the main java application.

---

<div class="post-metadata">

**Author:** ![heba](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/heba/32/134548_2.png) [@heba](https://discuss.elastic.co/u/heba)\
**Post date:** [May 16, 2024, 1:41pm UTC](https://discuss.elastic.co/t/attaching-apm-agent-attach-cli-jar-to-a-running-process-that-already-has-javaagents/321595/2 "2024-05-16T13:41:37Z")

</div>

Hello I am facing the same issue did you find answer
