Disable jar hell

Hi,

Is there any way to disable jar hell?

1 Like

No.

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

What is the problem you have?

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)

Read https://github.com/elastic/elasticsearch/blob/master/CONTRIBUTING.md

There is a chapter regarding this.

HTH

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.

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

:wink:

I have progressed:

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

But still have:

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

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

@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!

1 Like

Please format your code using </> icon as explained in this guide. 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?

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