# APM agent telling jps is not installed, though it is

**URL:** <https://discuss.elastic.co/t/apm-agent-telling-jps-is-not-installed-though-it-is/245891>\
**Category:** APM\
**Tags:** java\
**Created:** [August 21, 2020, 9:39am UTC](https://discuss.elastic.co/t/apm-agent-telling-jps-is-not-installed-though-it-is/245891 "2020-08-21T09:39:05Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![sbienert](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@sbienert](https://discuss.elastic.co/u/sbienert)\
**Post date:** [August 21, 2020, 9:39am UTC](https://discuss.elastic.co/t/apm-agent-telling-jps-is-not-installed-though-it-is/245891/1 "2020-08-21T09:39:06Z")

</div>

Hello,

I am trying to run the APM agent 1.17.0-standalone.jar on an Ubuntu 16.04.7 LTS machine with OpenJDK version 1.8.0\_265. When I execute the command  
` java -jar apm-agent-attach-1.17.0-standalone.jar -i '/opt/application/cl0501/*/*.jar' --continuous --config service_name=apm_mbse --config server_urls=http://server:8211`  
as the root user I get the following error message:

```
Exception in thread "main" java.lang.IllegalStateException: Matching JVMs with --include or --exclude requires jps to be installed
        at co.elastic.apm.attach.RemoteAttacher.main(RemoteAttacher.java:63)

```

However JPS is installed. When I execute "jps" on the machine, it lists me all the running JVMs. What can the problem be?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![Sylvain\_Juge](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sylvain_juge/32/55521_2.png) [@Sylvain\_Juge](https://discuss.elastic.co/u/Sylvain_Juge)\
**Post date:** [August 21, 2020, 1:16pm UTC](https://discuss.elastic.co/t/apm-agent-telling-jps-is-not-installed-though-it-is/245891/2 "2020-08-21T13:16:05Z")

</div>

Hi @sbienert,

Can you provide the output of the following commands:

```auto
java -version
which java
which jps
echo $JAVA_HOME

```

The JAVA\_HOME environment variable is used to locate path to `jps` binary, which is searched using $PATH variable by interactive shell.

---

<div class="post-metadata">

**Author:** ![sbienert](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@sbienert](https://discuss.elastic.co/u/sbienert)\
**Post date:** [August 21, 2020, 1:33pm UTC](https://discuss.elastic.co/t/apm-agent-telling-jps-is-not-installed-though-it-is/245891/3 "2020-08-21T13:33:30Z")

</div>

Thanks for your answer.

java -version outputs:

```
openjdk version "1.8.0_265"
OpenJDK Runtime Environment (build 1.8.0_265-8u265-b01-0ubuntu2~16.04-b01)
OpenJDK 64-Bit Server VM (build 25.265-b01, mixed mode)

```

which java outputs:  
`/usr/bin/java`

which jps outputs:  
`/usr/bin/jps`

echo $JAVA\_HOME outputs:  
`/usr/lib/jvm/java-8-oracle`

---

<div class="post-metadata">

**Author:** ![Sylvain\_Juge](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sylvain_juge/32/55521_2.png) [@Sylvain\_Juge](https://discuss.elastic.co/u/Sylvain_Juge)\
**Post date:** [August 21, 2020, 4:38pm UTC](https://discuss.elastic.co/t/apm-agent-telling-jps-is-not-installed-though-it-is/245891/4 "2020-08-21T16:38:24Z")

</div>

I've managed to reproduce the issue, it's definitely a fun one due to ubuntu using symlinks for the `java` binary.

I have opened a PR that should allow to use the value set with JAVA\_HOME instead to find the path to the `jps` binary (not part of the JRE, and only in the JDK).

> <https://github.com/elastic/apm-agent-java/pull/1352>

---

<div class="post-metadata">

**Author:** ![Sylvain\_Juge](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sylvain_juge/32/55521_2.png) [@Sylvain\_Juge](https://discuss.elastic.co/u/Sylvain_Juge)\
**Post date:** [August 24, 2020, 1:30pm UTC](https://discuss.elastic.co/t/apm-agent-telling-jps-is-not-installed-though-it-is/245891/5 "2020-08-24T13:30:40Z")

</div>

The fix has been merged in master and will be included in the next release.

You can use artifacts from the CI in the mean time: [https://apm-ci.elastic.co/blue/organizations/jenkins/apm-agent-java%2Fapm-agent-java-mbp/detail/master/505/artifacts](https://apm-ci.elastic.co/blue/organizations/jenkins/apm-agent-java%2Fapm-agent-java-mbp/detail/master/505/artifacts)

---

<div class="post-metadata">

**Author:** ![sbienert](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@sbienert](https://discuss.elastic.co/u/sbienert)\
**Post date:** [September 1, 2020, 8:04am UTC](https://discuss.elastic.co/t/apm-agent-telling-jps-is-not-installed-though-it-is/245891/6 "2020-09-01T08:04:32Z")

</div>

Thanks a lot!

---

<div class="post-metadata">

**Author:** ![sbienert](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@sbienert](https://discuss.elastic.co/u/sbienert)\
**Post date:** [September 3, 2020, 10:45am UTC](https://discuss.elastic.co/t/apm-agent-telling-jps-is-not-installed-though-it-is/245891/7 "2020-09-03T10:45:35Z")

</div>

Hi @Sylvain_Juge,

can you confirm that in the apm-agent-attach-1.18.1.RC1-SNAPSHOT-standalone the detection of the jars with --include flag and the regex pattern inside works? I do not get the jps error anymore but I tried several regex patterns for the paths to the jars and they do not seem the get the jar. The log says "Not attaching to ... bacause it is not included or excluded". When I put my regex pattern in a regex debugger, it does get the path though.

---

<div class="post-metadata">

**Author:** ![Sylvain\_Juge](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sylvain_juge/32/55521_2.png) [@Sylvain\_Juge](https://discuss.elastic.co/u/Sylvain_Juge)\
**Post date:** [September 7, 2020, 7:03am UTC](https://discuss.elastic.co/t/apm-agent-telling-jps-is-not-installed-though-it-is/245891/8 "2020-09-07T07:03:02Z")

</div>

Hi @sbienert,

Can you provide me a full example of the command line you are using with the output of `jps -lv` so I can check ? (make sure there is no confidential info in it please).

---

<div class="post-metadata">

**Author:** ![sbienert](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@sbienert](https://discuss.elastic.co/u/sbienert)\
**Post date:** [September 7, 2020, 7:33am UTC](https://discuss.elastic.co/t/apm-agent-telling-jps-is-not-installed-though-it-is/245891/9 "2020-09-07T07:33:46Z")

</div>

Hi @Sylvain_Juge,

I found out the issue. I think it only detects the JVM if the full line of the jps output is fetched by the regex pattern. Meaning if I my regex pattern in the include-flag ends with ".jar" it does not work, I would have to end it with ".jar.\*" e.g. but in the documentation there is one example where it also ends with ".jar" and beneath it says that the regex pattern only has to match the path to the jar or the classname.

jps -l outputs:  
`32295 sun.tools.jps.Jps`

My command I execute:

> java -jar apm-agent-attach-1.18.1.RC1-SNAPSHOT-standalone.jar --include '.\*application.jar' --continuous --config service\_name=application\_apm --config server\_urls=[http://address:8211](http://address:8211)

I tried with a several other patterns too but only works when I do a wildcard end. Don't want to post the output because I would have to change potentially sensible data, but it says for each application that it's not attaching because its not included and not excluded.

---

<div class="post-metadata">

**Author:** ![Sylvain\_Juge](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sylvain_juge/32/55521_2.png) [@Sylvain\_Juge](https://discuss.elastic.co/u/Sylvain_Juge)\
**Post date:** [September 7, 2020, 7:50am UTC](https://discuss.elastic.co/t/apm-agent-telling-jps-is-not-installed-though-it-is/245891/10 "2020-09-07T07:50:13Z")

</div>

Happy to know that you managed to find the issue here. I meant `jps -lv` in my previous message (I've since fixed it just in case someones struggles with this again).

I will check documentation to see how we can improve this.

---

<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:** [September 28, 2020, 3:50am UTC](https://discuss.elastic.co/t/apm-agent-telling-jps-is-not-installed-though-it-is/245891/11 "2020-09-28T03:50:29Z")

</div>

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