Jar Hell when staring integration test

I have a plugin which i decided to move to ES 2.2.

This is what I get when integration test start (ESIntegTestCase)

    co*grationTest  Time elapsed: 0.008 sec  <<< 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:99)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:348)
	at com.carrotsearch.randomizedtesting.RandomizedRunner$2.run(RandomizedRunner.java:582)
    Caused by: java.lang.IllegalStateException: jar hell!
    class: org.hamcrest.BaseDescription
    jar1: /home/prog/.m2/repository/org/hamcrest/hamcrest-all/1.3/hamcrest-all-1.3.jar
    jar2: /home/prog/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar

Any ideas?

This is what I have in dependencies

...
    <lucene.version>5.4.1</lucene.version>
    <elasticsearch.version>2.2.0</elasticsearch.version>
    <testframework.version>2.2.0</testframework.version>
...
  <dependencies>
    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
        <version>${elasticsearch.version}</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>

    <dependency>
      <groupId>org.elasticsearch</groupId>
      <artifactId>elasticsearch</artifactId>
      <version>${elasticsearch.version}</version>
      <scope>test</scope>
      <type>test-jar</type>
    </dependency>

    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-all</artifactId>
      <version>1.3</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.lucene</groupId>
      <artifactId>lucene-test-framework</artifactId>
      <version>${lucene.version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
      <type>jar</type>
    </dependency>

    <dependency>
      <groupId>com.carrotsearch.randomizedtesting</groupId>
      <artifactId>randomizedtesting-runner</artifactId>
      <version>${testframework.version}</version>
    </dependency>

    <dependency>
      <groupId>net.java.dev.jna</groupId>
      <artifactId>jna</artifactId>
      <version>4.1.0</version>
      <type>jar</type>
      <scope>test</scope>
    </dependency>
  </dependencies>

I'll also add that when I remove hamcrest dependency ES test fails with

java.lang.NoClassDefFoundError: org/hamcrest/Matchers
	at org.elasticsearch.test.ESIntegTestCase.afterInternal(ESIntegTestCase.java:595)
	at org.elasticsearch.test.ESIntegTestCase.after(ESIntegTestCase.java:1968)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

I added exclusion for hamcrest-core to maven dependencies and it works :slightly_smiling:

from which dependency are you excluding hamcrest-core

I excluded it from junit

1 Like