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

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.

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:

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