Resolving Jar hell

I have a custom plugin for Elasticsearch which has a dependency on httpclient and httpcore jar files. I see that these jars are part of Elasticsearch installation and hence want to use them instead of packaging these jars in my custom plugin.
So, I updated ES_CLASSPATH variable in $ES_HOME/bin/elasticsearch-env as follows:

With above configuration I trying to start Elasticsearch server but I am getting below error:

Caused by: java.lang.IllegalStateException: jar hell! duplicate codebases between plugin and core: [file:/usr/share/elasticsearch/modules/reindex/httpclient-4.5.2.jar, file:/usr/share/elasticsearch/modules/reindex/httpcore-4.4.5.jar]
at org.elasticsearch.plugins.PluginsService.checkBundleJarHell( ~[elasticsearch-6.8.4.jar:6.8.4]
... 14 more

If I remove including these jars in ES_CLASSPATH variable and try to start Elasticsearch server, I am getting below error:

Caused by: java.lang.ClassNotFoundException: org.apache.http.HttpEntity
at ~[?:1.8.0_40]
at java.lang.ClassLoader.loadClass( ~[?:1.8.0_40]
at ~[?:1.8.0_40]
at java.lang.ClassLoader.loadClass( ~[?:1.8.0_40]
... 15 more

So how can I add httpclient and httpcore jars to my plugin classpath?

Thanks in advance.

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