# Programmatic setup for Java agent not reading server URL setting

**URL:** https://discuss.elastic.co/t/programmatic-setup-for-java-agent-not-reading-server-url-setting/318522
**Category:** APM
**Tags:** java
**Created:** [November 9, 2022, 8:39am UTC](https://discuss.elastic.co/t/programmatic-setup-for-java-agent-not-reading-server-url-setting/318522 "2022-11-09T08:39:25Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Ong](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ong/32/40766_2.png) [@Ong](https://discuss.elastic.co/u/Ong)
#### Post date: [November 9, 2022, 8:39am UTC](https://discuss.elastic.co/t/programmatic-setup-for-java-agent-not-reading-server-url-setting/318522/1 "2022-11-09T08:39:25Z")

</div>

I am setting up APM for a Springboot Java application on maven. The APM server is running on ECE. I followed the guide on the Elastic documentation:  
[Programmatic API setup](https://www.elastic.co/guide/en/apm/agent/java/current/setup-attach-api.html)  
[Configuration](https://www.elastic.co/guide/en/apm/agent/java/current/configuration.html#configuration)

I put the APM settings inside src/main/resources/elasticapm.properties

```auto
elastic.apm.service_name=my_app
elastic.apm.server_url=https://27e366e292694865adf03548593877db.apm.ece-playground.dev.org:9243
elastic.apm.application_packages=org.dev.prototype
elastic.apm.secret_token=Token123

```

When the application starts up, I noticed that the agent is trying to connect to the default localhost:8200 instead of the actual APM server.

> WARN co.elastic.apm.agent.report.ApmServerHealthChecker - Elastic APM Server [http://localhost:8200/](http://localhost:8200/) is not available (Connection refused: connect)

I also tried putting all the APM settings in the default Springboot application.properties but the outcome is still the same.

Is there any missing step in the above?

**Kibana version** : 8.2,3

**Elasticsearch version** : 8.2.3

**APM Server version** : 8.2.3

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

**Browser version** : Chrome 107.0.5304.89

**Fresh install or upgraded from other version?** Fresh setup

---

<div class="post-metadata">

### Author: ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)
#### Post date: [November 9, 2022, 9:19am UTC](https://discuss.elastic.co/t/programmatic-setup-for-java-agent-not-reading-server-url-setting/318522/2 "2022-11-09T09:19:26Z")

</div>

If you look at your agent log, you would see that during startup it prints at `INFO` level the configuration options that it found in your setup (value and source). That would help you verify that what you configured is actually being picked up.  
In this case, it seems that you used the wrong config option names- as you can see in the docs (for example, the [`server_url`](https://www.elastic.co/guide/en/apm/agent/java/current/config-reporter.html#config-server-url) one), when setting through a property file, you don't need the `elastic.apm` prefix, only the actual config option name (for example: `server_url`). This prefix is required if you configure through system properties.

---

<div class="post-metadata">

### Author: ![Ong](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ong/32/40766_2.png) [@Ong](https://discuss.elastic.co/u/Ong)
#### Post date: [November 9, 2022, 10:39am UTC](https://discuss.elastic.co/t/programmatic-setup-for-java-agent-not-reading-server-url-setting/318522/3 "2022-11-09T10:39:23Z")

</div>

Thank you. I have removed the elastic.apm prefix and the app is able to read the values correctly.

---

<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 30, 2022, 6:39am UTC](https://discuss.elastic.co/t/programmatic-setup-for-java-agent-not-reading-server-url-setting/318522/4 "2022-11-30T06:39:30Z")

</div>

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