# Apm-agent-java don't work

**URL:** https://discuss.elastic.co/t/apm-agent-java-dont-work/315742
**Category:** APM
**Tags:** java
**Created:** [October 4, 2022, 7:05am UTC](https://discuss.elastic.co/t/apm-agent-java-dont-work/315742 "2022-10-04T07:05:36Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![odelacruzc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/odelacruzc/32/48992_2.png) [@odelacruzc](https://discuss.elastic.co/u/odelacruzc)
#### Post date: [October 4, 2022, 7:05am UTC](https://discuss.elastic.co/t/apm-agent-java-dont-work/315742/1 "2022-10-04T07:05:37Z")

</div>

Hi friends, I configured elastic-agent with elastic-agent-java to monitoring app myapp.jar, but I have the follow error:

```auto
ERROR co.elastic.apm.agent.report.IntakeV2ReportingEventHandler - Error sending data to APM server: Server returned HTTP response code: 403 for URL: [https://54c680e5619d41b690de8c04fe592dcb.apm.us-central1.gcp.cloud.es.io:443/intake/v2/events](https://54c680e5619d41b690de8c04fe592dcb.apm.us-central1.gcp.cloud.es.io/intake/v2/events), response code is 403
2022-10-04 06:56:56,926 [elastic-apm-server-reporter] WARN co.elastic.apm.agent.report.IntakeV2ReportingEventHandler - {
"accepted": 0,
"errors": [
{
"message": "unauthorized: anonymous access not permitted for agent \"java\""
}
]
}

```

---

<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: [October 4, 2022, 10:14am UTC](https://discuss.elastic.co/t/apm-agent-java-dont-work/315742/2 "2022-10-04T10:14:40Z")

</div>

Looks like you have to configure the secret token. See also [Secret token | APM User Guide [8.4] | Elastic](https://www.elastic.co/guide/en/apm/guide/current/secret-token.html)

---

<div class="post-metadata">

### Author: ![odelacruzc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/odelacruzc/32/48992_2.png) [@odelacruzc](https://discuss.elastic.co/u/odelacruzc)
#### Post date: [October 6, 2022, 2:17pm UTC](https://discuss.elastic.co/t/apm-agent-java-dont-work/315742/3 "2022-10-06T14:17:08Z")

</div>

Hi @felixbarny , I have the follow configuration to instrument agent Java with the server APM and run this command to up the app:

The secret tocket is configured. But whe I start the app only start the app or if I change de sort of command only start the agent, so I think that the command is wrong.

`java -Xms512m -Xmx6144m -javaagent:/home/centos/app/digitall/apps/elastic-agent/elastic-apm-agent-1.34.1.jar -Delastic.apm.service_name=digitall-rest -Delastic.apm.server_url= https://54c680e5619d41b690de8c04fe592dcb.apm.us-central1.gcp.cloud.es.io:443 -Delastic.apm.secret_token= **** -Delastic.apm.environment=dev -Delastic.apm.application_packages=org.example -jar digitall-rest-1.0.jar --spring.config.location=file:application.properties`

Attatch configuration agen\_policy wint apm Integration.

 ![agent_policy_conf](https://us1.discourse-cdn.com/elastic/original/3X/9/2/927978b4e09afaefd7b14d10ca22973378398f45.png)

---

<div class="post-metadata">

### Author: ![Jonas\_Kunz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jonas_kunz/32/110740_2.png) [@Jonas\_Kunz](https://discuss.elastic.co/u/Jonas_Kunz)
#### Post date: [October 11, 2022, 10:22am UTC](https://discuss.elastic.co/t/apm-agent-java-dont-work/315742/4 "2022-10-11T10:22:42Z")

</div>

Hi @odelacruzc ,

Could you provide [debug logs](https://www.elastic.co/guide/en/apm/agent/java/1.x/trouble-shooting.html#trouble-shooting-logging-procedure) from your agent? This will help us identify potential configuration issues.

---

<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: [November 1, 2022, 6:23am UTC](https://discuss.elastic.co/t/apm-agent-java-dont-work/315742/5 "2022-11-01T06:23:12Z")

</div>

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