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:
ES_CLASSPATH="$ES_HOME/lib/*:$ES_HOME/modules/reindex/httpclient-4.5.2.jar:$ES_HOME/modules/reindex/httpcore-4.4.5.jar"

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(PluginsService.java:517) ~[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 java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[?:1.8.0_40]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_40]
at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:810) ~[?:1.8.0_40]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?: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.