Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JarHell check fails for Java 9 libraries (module-info.class) #32985

Closed
jamesdbaker opened this issue Aug 20, 2018 · 6 comments
Closed

JarHell check fails for Java 9 libraries (module-info.class) #32985

jamesdbaker opened this issue Aug 20, 2018 · 6 comments
Assignees
Labels
>bug :Core/Infra/Core Core issues without another label

Comments

@jamesdbaker
Copy link

Elasticsearch version:

6.3.2, Build: default/zip/053779d/2018-07-20T05:20:23.451332Z, JVM: 9.0.4

JVM version:

java version "9.0.4"
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)

OS version:

Linux dendesk-0260147 4.15.0-32-generic # 35~16.04.1-Ubuntu SMP Fri Aug 10 21:54:34 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Description of the problem including expected versus actual behavior:

I'm developing a new ingest processor that uses two libraries written for Java 9. As they're written for Java 9, both have a module-info.class in the default package, but the JarHell check is detecting this and throwing an error.

java.lang.RuntimeException: found jar hell in test classpath

	at org.elasticsearch.bootstrap.BootstrapForTesting.<clinit>(BootstrapForTesting.java:95)
	at org.elasticsearch.test.ESTestCase.<clinit>(ESTestCase.java:197)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:375)
	at com.carrotsearch.randomizedtesting.RandomizedRunner$2.run(RandomizedRunner.java:592)
Caused by: java.lang.IllegalStateException: jar hell!
class: module-info
jar1: /home/bakerj/.m2/repository/io/annot8/components/0.1-SNAPSHOT/components-0.1-SNAPSHOT.jar
jar2: /home/bakerj/.m2/repository/io/annot8/core/0.1-SNAPSHOT/core-0.1-SNAPSHOT.jar
	at org.elasticsearch.bootstrap.JarHell.checkClass(JarHell.java:273)
	at org.elasticsearch.bootstrap.JarHell.checkJarHell(JarHell.java:190)
	at org.elasticsearch.bootstrap.JarHell.checkJarHell(JarHell.java:86)
	at org.elasticsearch.bootstrap.BootstrapForTesting.<clinit>(BootstrapForTesting.java:93)
	... 4 more

As it is expected that module-info.class is found in the same place in multiple JARs, a exemption from the check is probably needed.

This has also been flagged by other users here: https://stackoverflow.com/questions/51217252/elasticsearch-6-3-0-jarhell-module-info-class

Steps to reproduce:

  1. Clone the following project: https://github.com/jamesdbaker/es-extract
  2. Run mvn test
@alpar-t alpar-t added :Delivery/Build Build or test infrastructure :Core/Infra/Core Core issues without another label labels Aug 20, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

@alpar-t alpar-t added the >bug label Aug 20, 2018
@alpar-t alpar-t self-assigned this Aug 20, 2018
@jasontedor jasontedor removed the :Delivery/Build Build or test infrastructure label Aug 20, 2018
@alpar-t
Copy link
Contributor

alpar-t commented Aug 20, 2018

@jamesdbaker I was able to reproduce this with log4j 2.10 but not 2.11 which elasticsearch uses since 0a67cb4 . Since this is just for testing you could probably configure your pom to use it as a workaround. I will open a PR to fix jar hell soon.

alpar-t added a commit to alpar-t/elasticsearch that referenced this issue Aug 20, 2018
@jamesdbaker
Copy link
Author

@atorok - Thanks, I will check when I'm back in the office tomorrow. In my case though, I'm not sure log4j was the problem as the two JARs it's referencing don't include log4j. I think it's a more generic Java 9 problem. That said, hopefully whatever fix you put in place will solve both.

I'll let you know the outcome of the workaround tomorrow.

@alpar-t
Copy link
Contributor

alpar-t commented Aug 21, 2018

@jamesdbaker that's right, I was referring to the example from stack overflow. You could put the meta-info class in different packages to avoid the jar hell. The fix I did will fix you're project as well.

@jmmk
Copy link

jmmk commented Oct 1, 2018

@atorok Will this be backported to previous ES versions?

If I understand correctly, anyone on an older version of ES cannot have more than one instance of module-info.classon their classpath without tests failing with "found jar hell in test classpath"

@jasontedor
Copy link
Member

We have backported this change to our 6.x branch which is the development branch for the next minor release, but we will not be taking this change back any further than that.

rhauch added a commit to rhauch/kafka-connect-elasticsearch that referenced this issue Nov 16, 2018
The `module-info` files will appear in multiple JARs, and they are not duplicates. The ES JarHell utility that the Elasticsearch project uses in their tests and base classes for tests (which we inherit and use in our tests) doesn’t take the `module-info` files into account.

A similar fix was made for and backported to all ES 6.x branches (see elastic/elasticsearch#32985), but it was intentionally not backported.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Core/Infra/Core Core issues without another label
Projects
None yet
Development

No branches or pull requests

5 participants