# Facing jar hell issue when trying to embed some code in server src using external libraries

**URL:** <https://discuss.elastic.co/t/facing-jar-hell-issue-when-trying-to-embed-some-code-in-server-src-using-external-libraries/361821>\
**Category:** Elasticsearch\
**Created:** [June 21, 2024, 5:31am UTC](https://discuss.elastic.co/t/facing-jar-hell-issue-when-trying-to-embed-some-code-in-server-src-using-external-libraries/361821 "2024-06-21T05:31:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anshulvika360](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anshulvika360/32/135441_2.png) [@anshulvika360](https://discuss.elastic.co/u/anshulvika360)\
**Post date:** [June 21, 2024, 5:31am UTC](https://discuss.elastic.co/t/facing-jar-hell-issue-when-trying-to-embed-some-code-in-server-src-using-external-libraries/361821/1 "2024-06-21T05:31:21Z")

</div>

I am trying to enrich logs with some additional information when using bulk api. For this i have added my custom code in server src. My code depends on few external libraries namely: hhtpclient,httpcore,comons codec,commons logging, jackson and gson. But these jars are causing conflicts on startup giving jar hell error. I have tried playing with shadow jar without any luck. How to use these jars in server code without getting conflict. I am using elasticsearch 7.4.2.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 21, 2024, 6:31am UTC](https://discuss.elastic.co/t/facing-jar-hell-issue-when-trying-to-embed-some-code-in-server-src-using-external-libraries/361821/2 "2024-06-21T06:31:12Z")

</div>

This is solved when switching to the new Java client. But for this you need at least 7.17.

Otherwise, in case it helps, I wrote a blog post almost 10 years ago about this:

> **[To shade or not to shade](https://www.elastic.co/blog/to-shade-or-not-to-shade)**
>
> Elasticsearch ships without shading from 2.0 onwards. If using Elasticsearch in a Java application, you may have to deal with Guava and Joda version conflicts....

Otherwise, it's not too hard to build your own client for very specific use cases, like bulk. I wrote mine here: [fscrawler/elasticsearch-client at master · dadoonet/fscrawler · GitHub](https://github.com/dadoonet/fscrawler/tree/master/elasticsearch-client)
