# Jar Hell when staring integration test

**URL:** <https://discuss.elastic.co/t/jar-hell-when-staring-integration-test/41885>\
**Category:** Elasticsearch\
**Created:** [February 16, 2016, 12:52pm UTC](https://discuss.elastic.co/t/jar-hell-when-staring-integration-test/41885 "2016-02-16T12:52:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pawel\_Rog](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pawel_rog/32/141223_2.png) [@Pawel\_Rog](https://discuss.elastic.co/u/Pawel_Rog)\
**Post date:** [February 16, 2016, 12:52pm UTC](https://discuss.elastic.co/t/jar-hell-when-staring-integration-test/41885/1 "2016-02-16T12:52:09Z")

</div>

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

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

```auto
    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

```auto
...
    <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

```auto
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)

```

---

<div class="post-metadata">

**Author:** ![Pawel\_Rog](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pawel_rog/32/141223_2.png) [@Pawel\_Rog](https://discuss.elastic.co/u/Pawel_Rog)\
**Post date:** [February 16, 2016, 1:45pm UTC](https://discuss.elastic.co/t/jar-hell-when-staring-integration-test/41885/2 "2016-02-16T13:45:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dadepo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadepo/32/19944_2.png) [@dadepo](https://discuss.elastic.co/u/dadepo)\
**Post date:** [July 14, 2016, 9:08am UTC](https://discuss.elastic.co/t/jar-hell-when-staring-integration-test/41885/3 "2016-07-14T09:08:28Z")

</div>

from which dependency are you excluding hamcrest-core

---

<div class="post-metadata">

**Author:** ![Pawel\_Rog](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pawel_rog/32/141223_2.png) [@Pawel\_Rog](https://discuss.elastic.co/u/Pawel_Rog)\
**Post date:** [July 14, 2016, 9:42am UTC](https://discuss.elastic.co/t/jar-hell-when-staring-integration-test/41885/4 "2016-07-14T09:42:40Z")

</div>

I excluded it from junit

---

<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:** [July 5, 2017, 10:35pm UTC](https://discuss.elastic.co/t/jar-hell-when-staring-integration-test/41885/5 "2017-07-05T22:35:45Z")

</div>


