# Java.lang.IllegalArgumentException with environment variable placeholder

**URL:** <https://discuss.elastic.co/t/java-lang-illegalargumentexception-with-environment-variable-placeholder/362901>\
**Category:** Elasticsearch\
**Created:** [July 10, 2024, 4:35pm UTC](https://discuss.elastic.co/t/java-lang-illegalargumentexception-with-environment-variable-placeholder/362901 "2024-07-10T16:35:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![EAC](https://avatars.discourse-cdn.com/v4/letter/e/f19dbf/32.png) [@EAC](https://discuss.elastic.co/u/EAC)\
**Post date:** [July 10, 2024, 4:35pm UTC](https://discuss.elastic.co/t/java-lang-illegalargumentexception-with-environment-variable-placeholder/362901/1 "2024-07-10T16:35:00Z")

</div>

Context of environment: Newbee engaged with the learning and building of a current-version single node elasticsearch-kibana-logstash stack with manually configured security, within a current virtual Ubuntu machine.

Context of Problem: Running and re-running bin/elasticsearch-certutil and -keystore tools, regardless of if installed elasticsearch is running or not.

The yet-unresolved issue: At some point after running a bin/elasticsearch- tool, Java throws an IllegalArgumentException: "Could not resolve placeholder 'ES\_PATH\_CONF' which prevents any further successful engagement with those elasticsearch- tools.

Now I do know what ES\_PATH\_CONF is, what it should be, and where it is defined. But I have no clue why Java cares.

What have I done to get out of this so far? Go back to a prior-saved virtual machine state where the problem has not yet shown its face.

Attempts to prevent this issue:

1. run the bin/elasticsearch- tool with "sudo -E ..." rather than with just "sudo ...". This seemed to enable me to run and rerun the tools for a longer period of time before the Exception starts.

Attempts to clear this issue:

1. Rebooting the system, which does not clear the issue, which continues to stop further use of the -certutil and -keystore elasticsearch tools.

Full Exception from "sudo -E ./bin/elasticsearch-keystore list":  
'Exception in thread "main" java.lang.IllegalArgumentException: Could not resolve placeholder 'ES\_PATH\_CONF''  
'at org.elasticsearch.common.settings.PropertyPlaceholder.parseStringValue(PropertyPlaceholder.java:102)'  
'at org.elasticsearch.common.settings.PropertyPlaceholder.replacePlaceholders(PropertyPlaceholder.java:57)'  
'at org.elasticsearch.common.settings.Settings$Builder.replacePropertyPlaceholders(Settings.java:1314)'  
'at org.elasticsearch.node.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:56)'  
'at org.elasticsearch.common.cli.EnvironmentAwareCommand.createEnv(EnvironmentAwareCommand.java:110)'  
'at org.elasticsearch.common.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:54)'  
'at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:85)'  
'at org.elasticsearch.cli.MultiCommand.execute(MultiCommand.java:94)'  
'at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:85)'  
'at org.elasticsearch.cli.Command.main(Command.java:50)'  
'at org.elasticsearch.launcher.CliToolLauncher.main(CliToolLauncher.java:64)'

Full Exception from "sudo -E ./bin/elasticsearch-keystore http":  
'Exception in thread "main" java.lang.IllegalArgumentException: Could not resolve placeholder 'ES\_PATH\_CONF''  
'at org.elasticsearch.common.settings.PropertyPlaceholder.parseStringValue(PropertyPlaceholder.java:102)'  
'at org.elasticsearch.common.settings.PropertyPlaceholder.replacePlaceholders(PropertyPlaceholder.java:57)'  
'at org.elasticsearch.common.settings.Settings$Builder.replacePropertyPlaceholders(Settings.java:1314)'  
'at org.elasticsearch.node.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:56)'  
'at org.elasticsearch.common.cli.EnvironmentAwareCommand.createEnv(EnvironmentAwareCommand.java:110)'  
'at org.elasticsearch.common.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:54)'  
'at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:85)'  
'at org.elasticsearch.cli.MultiCommand.execute(MultiCommand.java:94)'  
'at org.elasticsearch.xpack.security.cli.CertificateTool.execute(CertificateTool.java:161)'  
'at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:85)'  
'at org.elasticsearch.cli.Command.main(Command.java:50)'  
'at org.elasticsearch.launcher.CliToolLauncher.main(CliToolLauncher.java:64)'

Any suggestions in what direction I should start looking to learn what phenomena is setting me up for this IllegalArgumentException would be much appreciated!  
Thank you for your time and consideration!

---

<div class="post-metadata">

**Author:** ![EAC](https://avatars.discourse-cdn.com/v4/letter/e/f19dbf/32.png) [@EAC](https://discuss.elastic.co/u/EAC)\
**Post date:** [July 12, 2024, 6:11pm UTC](https://discuss.elastic.co/t/java-lang-illegalargumentexception-with-environment-variable-placeholder/362901/2 "2024-07-12T18:11:49Z")

</div>

Regardless of knowing why, this phenomena can be created with edits to the /etc/elasticsearch/elasticsearch.yml file by inserting a prepend of "${ES\_PATH\_CONF}/" to entries containing "certs/".

Neither full path prepends of "/etc/elasticsearch/" nor the untouched installed settings with "certs/" create the phenomena when going to execute tools: elasticsearch-certutil, elasticsearch-keystore, regardless of the installed elasticsearch running or not.

Go ahead, have some fun and give it a try!

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [July 15, 2024, 5:46am UTC](https://discuss.elastic.co/t/java-lang-illegalargumentexception-with-environment-variable-placeholder/362901/3 "2024-07-15T05:46:51Z")

</div>

This error means that the `ES_PATH_CONF` variable is not set. To fix it, set the environment variable. I opened [#110858](https://github.com/elastic/elasticsearch/issues/110858) because I think we could make this error message clearer.

---

<div class="post-metadata">

**Author:** ![EAC](https://avatars.discourse-cdn.com/v4/letter/e/f19dbf/32.png) [@EAC](https://discuss.elastic.co/u/EAC)\
**Post date:** [July 15, 2024, 2:40pm UTC](https://discuss.elastic.co/t/java-lang-illegalargumentexception-with-environment-variable-placeholder/362901/4 "2024-07-15T14:40:39Z")

</div>

Thank you for looking in to this.

After adding '${ES\_PATH\_CONF}/' as a prepend to 'certs/....' in the elasticsearch.yml ssl configurations, you will get the same java IllegalArgumentException regardless of the ES\_PATH\_CONF environment variable being set or not.

These edits to elasticsearch.yml do not require restarting the elasticsearch service to see the IllegalArgumentException when going to execute elasticsearch-certutil or elasticsearch-keystore.

You can toggle back and forth to success or IllegalArgumentException failure by simply adding or removing the '${ES\_PATH\_CONF}/' prepend to 'certs/...' elasticsearch.yml configurations.

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [July 15, 2024, 5:46pm UTC](https://discuss.elastic.co/t/java-lang-illegalargumentexception-with-environment-variable-placeholder/362901/5 "2024-07-15T17:46:40Z")

</div>

> [@EAC](#):
>
> you will get the same java IllegalArgumentException regardless of the ES\_PATH\_CONF environment variable being set or not.

I can't reproduce this. When I set `${ES_PATH_CONF}` I do not get this error.
