# Java.lang.AssertionError with Integration Tests

**URL:** <https://discuss.elastic.co/t/java-lang-assertionerror-with-integration-tests/25124>\
**Category:** Elasticsearch\
**Created:** [July 8, 2015, 7:49am UTC](https://discuss.elastic.co/t/java-lang-assertionerror-with-integration-tests/25124 "2015-07-08T07:49:37Z")\
**Posts on this page:** 11\
**Page:** 1

<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 8, 2015, 7:49am UTC](https://discuss.elastic.co/t/java-lang-assertionerror-with-integration-tests/25124/1 "2015-07-08T07:49:37Z")

</div>

I am trying to use the Integration features that now comes with Elasticsearch. So I have my test class annotated with `@ClusterScope(scope = Scope.TEST)`, extending the `ElasticsearchIntegrationTest` and using the methods `createIndex()` and `Index()` to create and index data for testing, but when I run the test I get the following:

> java.lang.AssertionError: fix your classpath to have tests-framework.jar before lucene-core.jar  
> \_\_randomizedtesting.SeedInfo.seed([1B076E861944DDD3]:0)  
> org.apache.lucene.util.TestRuleSetupAndRestoreClassEnv.before(TestRuleSetupAndRestoreClassEnv.java:219)  
> org.apache.lucene.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:45)  
> org.apache.lucene.util.TestRuleStoreClassName$1.evaluate(TestRuleStoreClassName.java:42)  
> [...com.carrotsearch.randomizedtesting._]  
> org.apache.lucene.util.TestRuleAssertionsRequired$1.evaluate(TestRuleAssertionsRequired.java:54)  
> org.apache.lucene.util.TestRuleMarkFailure$1.evaluate(TestRuleMarkFailure.java:48)  
> org.apache.lucene.util.TestRuleIgnoreAfterMaxFailures$1.evaluate(TestRuleIgnoreAfterMaxFailures.java:65)  
> org.apache.lucene.util.TestRuleIgnoreTestSuites$1.evaluate(TestRuleIgnoreTestSuites.java:55)  
> [...com.carrotsearch.randomizedtesting._]  
> java.lang.Thread.run(Thread.java:745)

Any idea on how to fix this? Thanks!

---

<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:** [July 8, 2015, 8:01am UTC](https://discuss.elastic.co/t/java-lang-assertionerror-with-integration-tests/25124/2 "2015-07-08T08:01:30Z")

</div>

Yes. Put the test-framework before elasticsearch in your `pom.xml`.

Something like [https://github.com/elastic/elasticsearch/blob/master/plugins/pom.xml#L27-L55](https://github.com/elastic/elasticsearch/blob/master/plugins/pom.xml#L27-L55)

---

<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 8, 2015, 8:26am UTC](https://discuss.elastic.co/t/java-lang-assertionerror-with-integration-tests/25124/3 "2015-07-08T08:26:30Z")

</div>

Thanks @dadoonet for the reply.  
Yes, I have my dependencies ordered in a similar fashion, although I noticed I was missing

```
<dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <type>zip</type>
            <scope>test</scope>
</dependency>

```

in my dependencies; added it and it is still the same. I am running the test as a Junit test from within an IDE (IntelliJ) but the strange thing is the exception pops up randomly. Sometimes it runs without that exception, at most time, it throws it. That is the part I am not clear on what exactly is going on.

---

<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:** [July 8, 2015, 8:38am UTC](https://discuss.elastic.co/t/java-lang-assertionerror-with-integration-tests/25124/4 "2015-07-08T08:38:07Z")

</div>

This one is not needed.

What does your `pom.xml` look like?

---

<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 8, 2015, 8:55am UTC](https://discuss.elastic.co/t/java-lang-assertionerror-with-integration-tests/25124/5 "2015-07-08T08:55:13Z")

</div>

Here:

```
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>model-module</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>

    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>event-module</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>

    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
    </dependency>

    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
    </dependency>

    <!-- Test -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.lucene</groupId>
        <artifactId>lucene-test-framework</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
        <version>${es.version}</version>
        <scope>test</scope>
        <type>test-jar</type>
    </dependency>
    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
        <version>${es.version}</version>
        <type>zip</type>
        <scope>test</scope>
    </dependency>
</dependencies>
```

---

<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 8, 2015, 9:01am UTC](https://discuss.elastic.co/t/java-lang-assertionerror-with-integration-tests/25124/6 "2015-07-08T09:01:24Z")

</div>

Its interesting as I get the random exception even if I run `mvn clean test`

After running it successfully for 3 times, the 4th time popped up:

```
Failed tests: 
  ElasticSearchServiceTest.xx.xxx.ElasticSearchServiceTest fix your classpath to have tests-framework.jar before lucene-core.jar

```

I have no idea why!

---

<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:** [July 8, 2015, 9:09am UTC](https://discuss.elastic.co/t/java-lang-assertionerror-with-integration-tests/25124/7 "2015-07-08T09:09:11Z")

</div>

So we agree that `lucene-test-framework` is not the first one in your `pom.xml`?

Put it on the very top before anything else.

---

<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 8, 2015, 9:27am UTC](https://discuss.elastic.co/t/java-lang-assertionerror-with-integration-tests/25124/8 "2015-07-08T09:27:46Z")

</div>

Sure. But that can't explain the fact it sometimes work, can it?

So now I have my pom as:

```
<dependencies>
    <!-- Test -->
    <dependency>
        <groupId>org.apache.lucene</groupId>
        <artifactId>lucene-test-framework</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
    </dependency>
    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
        <version>${es.version}</version>
        <scope>test</scope>
        <type>test-jar</type>
    </dependency>
    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
        <version>${es.version}</version>
        <type>zip</type>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>model-module</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>

    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>event-module</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>

    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
    </dependency>

    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
    </dependency>
    
</dependencies>

```

but now I get this exception:

```
java.lang.NoSuchFieldError: LUCENE_4_10_4
	at org.elasticsearch.Version.<clinit>(Version.java:226)
	at org.elasticsearch.test.ElasticsearchTestCase.<clinit>(ElasticsearchTestCase.java:87)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:348)
	at com.carrotsearch.randomizedtesting.RandomizedRunner$1.run(RandomizedRunner.java:562)
```

---

<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:** [July 8, 2015, 9:40am UTC](https://discuss.elastic.co/t/java-lang-assertionerror-with-integration-tests/25124/9 "2015-07-08T09:40:31Z")

</div>

Sounds like you are mixing elasticsearch versions between tests/core here. But unsure.

---

<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 8, 2015, 10:47am UTC](https://discuss.elastic.co/t/java-lang-assertionerror-with-integration-tests/25124/10 "2015-07-08T10:47:42Z")

</div>

Seems the problem was with discrepancies in the elasticsearch and lucene versions. Checked to see the correct version of lucene to use with the version of elasticsearch I am running with, updated, and everything seems to be fine now...I have ran the test aprox. 10 times now and it consistently pass.

I would still be curious to know though, why I was experiencing the random failings when the version was off?

Anyways, thanks for pointing me in the direction of looking into the dependency versions!

---

<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 6, 2017, 12:02am UTC](https://discuss.elastic.co/t/java-lang-assertionerror-with-integration-tests/25124/11 "2017-07-06T00:02:54Z")

</div>


