# Disable jar hell

**URL:** <https://discuss.elastic.co/t/disable-jar-hell/104029>\
**Category:** Elasticsearch\
**Created:** [October 15, 2017, 5:05pm UTC](https://discuss.elastic.co/t/disable-jar-hell/104029 "2017-10-15T17:05:22Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![bendg25](https://avatars.discourse-cdn.com/v4/letter/b/57b2e6/32.png) [@bendg25](https://discuss.elastic.co/u/bendg25)\
**Post date:** [October 15, 2017, 5:05pm UTC](https://discuss.elastic.co/t/disable-jar-hell/104029/1 "2017-10-15T17:05:22Z")

</div>

Hi,

Is there any way to disable jar hell?

---

<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:** [October 15, 2017, 5:41pm UTC](https://discuss.elastic.co/t/disable-jar-hell/104029/2 "2017-10-15T17:41:11Z")

</div>

No.

Why would you? You don't want to have JAR conflicts in your classpath, right?

What is the problem you have?

---

<div class="post-metadata">

**Author:** ![bendg25](https://avatars.discourse-cdn.com/v4/letter/b/57b2e6/32.png) [@bendg25](https://discuss.elastic.co/u/bendg25)\
**Post date:** [October 15, 2017, 7:03pm UTC](https://discuss.elastic.co/t/disable-jar-hell/104029/3 "2017-10-15T19:03:00Z")

</div>

I am running with Intellij 2017.2.5, build 172.4343.14:  
It appears to be an idea\_rt.jar conflict on the classpath (assuming I am reading the error right). Full stack trace at bottom.

In terms of why I would want to disable it. Reason is _most_ jar conflicts don't result in major issues. When they do, they tend to throw exceptions anyway, and I am use to sorting these out myself. I can use mvn dependency:tree and exclude as neccesary. The trouble with having Jar Hell enabled in the ES project, in my opinion, is that it is a 'barrier to entry', it is something that causes people issues, when 90% of the time, the issues JarHell raises are not that important.

In the same way, the official ES docker image has defaulted to having authentication switched on. I am not arguing that this is desirable for test/production, but for development, it makes devs deal with those concerns way before they actually need to. There could be a mode / profile for people to invoke jar hell if they faced any issues.

Anyway, here is my stack trace:

Caused by: java.lang.IllegalStateException: jar hell!  
duplicate jar [/Applications/IntelliJ IDEA.app/Contents/lib/idea\_rt.jar] on classpath: /Applications/IntelliJ IDEA.app/Contents/lib/idea\_rt.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/junit/lib/junit-rt.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/junit/lib/junit5-rt.jar:..../Users/bengill/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/8.5.15/tomcat-embed-websocket-8.5.15.jar:/Users/bengill/.m2/repository/org/springframework/spring-webmvc/4.3.9.RELEASE/spring-webmvc-4.3.9.RELEASE.jar:/Users/bengill/dev/flo/app-api/target/classes:/Users/bengill/dev/flo/shared/target/classes:/Users/bengill/dev/flo/search-api/target/classes:/Applications/IntelliJ IDEA.app/Contents/lib/idea\_rt.jar  
at org.elasticsearch.bootstrap.JarHell.parseClassPath(JarHell.java:142)  
at org.elasticsearch.bootstrap.JarHell.parseClassPath(JarHell.java:99)  
at org.elasticsearch.bootstrap.JarHell.checkJarHell(JarHell.java:90)  
at org.elasticsearch.bootstrap.BootstrapForTesting.(BootstrapForTesting.java:89)

---

<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:** [October 15, 2017, 7:20pm UTC](https://discuss.elastic.co/t/disable-jar-hell/104029/4 "2017-10-15T19:20:35Z")

</div>

Read [https://github.com/elastic/elasticsearch/blob/master/CONTRIBUTING.md](https://github.com/elastic/elasticsearch/blob/master/CONTRIBUTING.md)

There is a chapter regarding this.

HTH

---

<div class="post-metadata">

**Author:** ![bendg25](https://avatars.discourse-cdn.com/v4/letter/b/57b2e6/32.png) [@bendg25](https://discuss.elastic.co/u/bendg25)\
**Post date:** [October 16, 2017, 4:56am UTC](https://discuss.elastic.co/t/disable-jar-hell/104029/5 "2017-10-16T04:56:38Z")

</div>

Thanks David,

That has solved that problem. Then I hit jarhell due to logging libraries (had to exlcude commons-logging), now I am onto another jarhell issue as I happen to have a duplicate Q generated class due to the way some of my persistent domain modules are structured, so even through this is completely harmless, I have to work out how to stop it generating Q classes on pom dependency modules.

This is why I dislike jarhell so much.

---

<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:** [October 16, 2017, 5:13am UTC](https://discuss.elastic.co/t/disable-jar-hell/104029/6 "2017-10-16T05:13:13Z")

</div>

Yeah. It’s annoying.... Until you discover that it’s going to protect yourself from doing bad things like:

> <https://github.com/elastic/elasticsearch/issues/20372>

😉

---

<div class="post-metadata">

**Author:** ![bendg25](https://avatars.discourse-cdn.com/v4/letter/b/57b2e6/32.png) [@bendg25](https://discuss.elastic.co/u/bendg25)\
**Post date:** [October 16, 2017, 5:34am UTC](https://discuss.elastic.co/t/disable-jar-hell/104029/7 "2017-10-16T05:34:43Z")

</div>

I have progressed:

1. Exclude mysema
2. securemock collision
3. Downgrade junit to 4.11
4. exclude hamcrest-core

But still have:

```auto
ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...

java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessDeclaredMembers")

	at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
	at java.security.AccessController.checkPermission(AccessController.java:884)
	at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
	at java.lang.Class.checkMemberAccess(Class.java:2348)
	at java.lang.Class.getDeclaredMethods(Class.java:1974)
	at org.junit.internal.MethodSorter.getDeclaredMethods(MethodSorter.java:54)
	at org.junit.runners.model.TestClass.<init>(TestClass.java:45)
	at com.carrotsearch.randomizedtesting.RandomizedRunner$12.run(RandomizedRunner.java:1053)
	at com.carrotsearch.randomizedtesting.RandomizedRunner$12.run(RandomizedRunner.java:1050)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.carrotsearch.randomizedtesting.RandomizedRunner.getAnnotatedFieldValues(RandomizedRunner.java:1050)
	at com.carrotsearch.randomizedtesting.RandomizedRunner.withClassRules(RandomizedRunner.java:885)
	at com.carrotsearch.randomizedtesting.RandomizedRunner.runSuite(RandomizedRunner.java:674)
	at com.carrotsearch.randomizedtesting.RandomizedRunner.access$200(RandomizedRunner.java:140)
	at com.carrotsearch.randomizedtesting.RandomizedRunner$2.run(RandomizedRunner.java:598)

Test ignored.

Test ignored.

Test ignored.

Test ignored.
REPRODUCE WITH: gradle null -Dtests.seed=E95D0993190E9325 -Dtests.class=com.sparksdev.flo.search.service.SearchIT -Dtests.locale=en-GB -Dtests.timezone=Europe/London
NOTE: Mac OS X 10.12.6 x86_64/Oracle Corporation 1.8.0_144 (64-bit)/cpus=8,threads=1,free=287936064,total=324534272
NOTE: All tests run in this JVM: [SearchIT]
Exception in thread "Thread-1" java.lang.ClassCastException: org.apache.logging.log4j.simple.SimpleLoggerContext cannot be cast to org.apache.logging.log4j.core.LoggerContext
	at org.elasticsearch.test.ESTestCase.lambda$static$0(ESTestCase.java:171)
	at java.lang.Thread.run(Thread.java:748)
	Suppressed: java.security.AccessControlException: access denied ("org.elasticsearch.ThreadPermission" "modifyArbitraryThreadGroup")
		at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
		at java.security.AccessController.checkPermission(AccessController.java:884)
		at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
		at org.elasticsearch.SecureSM.checkThreadGroupAccess(SecureSM.java:194)
		at org.elasticsearch.SecureSM.checkAccess(SecureSM.java:141)
		at java.lang.ThreadGroup.checkAccess(ThreadGroup.java:315)
		at java.lang.ThreadGroup.getParent(ThreadGroup.java:167)
		at com.carrotsearch.randomizedtesting.RandomizedContext.context(RandomizedContext.java:240)
		at com.carrotsearch.randomizedtesting.RandomizedContext.current(RandomizedContext.java:134)
		at com.carrotsearch.randomizedtesting.RandomizedRunner.augmentStackTrace(RandomizedRunner.java:1848)
		at com.carrotsearch.randomizedtesting.RunnerThreadGroup.uncaughtException(RunnerThreadGroup.java:20)
		at java.lang.Thread.dispatchUncaughtException(Thread.java:1959)

Process finished with exit code 255

```

---

<div class="post-metadata">

**Author:** ![bendg25](https://avatars.discourse-cdn.com/v4/letter/b/57b2e6/32.png) [@bendg25](https://discuss.elastic.co/u/bendg25)\
**Post date:** [October 16, 2017, 5:54am UTC](https://discuss.elastic.co/t/disable-jar-hell/104029/8 "2017-10-16T05:54:05Z")

</div>

I have it working now, reverting back to using this worked for me:

```auto
@RunWith(com.carrotsearch.randomizedtesting.RandomizedRunner.class)
@ContextConfiguration(classes = { SearchTestSpringConfig.class } )
@ThreadLeakScope(ThreadLeakScope.Scope.NONE)
public class SearchIT extends ESTestCase {

```

(rather than using `ESIntegTestCase`).

That was harder than it should have been!

---

<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:** [October 16, 2017, 6:06am UTC](https://discuss.elastic.co/t/disable-jar-hell/104029/9 "2017-10-16T06:06:01Z")

</div>

Please format your code using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

I edited your posts.

> That was harder than it should have been!

Hard to say. I don't really know what you are doing. Building a plugin may be?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 13, 2017, 6:06am UTC](https://discuss.elastic.co/t/disable-jar-hell/104029/10 "2017-11-13T06:06:09Z")

</div>

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