Build Plugin ElasticSearch have error when UnitTest

Hi,

I writing plugin Elasticsearch by Java and build by maven . But when I run as Maven Test it has error below:

ERROR 0.00s | VietnameseAnalysisIntegrationTest (suite) <<<

Throwable #1: java.lang.RuntimeException: found jar hell in test classpath
at org.elasticsearch.bootstrap.BootstrapForTesting.(BootstrapForTesting.java:95)
at org.elasticsearch.test.ESTestCase.(ESTestCase.java:197)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at com.carrotsearch.randomizedtesting.RandomizedRunner$2.run(RandomizedRunner.java:592)
Caused by: java.lang.IllegalStateException: jar hell!
class: com.sun.jna.AltCallingConvention
jar1: /home/trantrungtruc/.m2/repository/org/elasticsearch/jna/4.5.1/jna-4.5.1.jar
jar2: /home/trantrungtruc/.m2/repository/net/java/dev/jna/jna/4.1.0/jna-4.1.0.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.(BootstrapForTesting.java:93)
... 4 more
Completed [1/2 (1!)] in 0.45s, 0 tests, 1 error <<< FAILURES!

Suite: org.elasticsearch.index.analysis.VietnameseAnalysisTest
ERROR 0.00s | VietnameseAnalysisTest.initializationError <<<

Throwable #1: java.lang.NoClassDefFoundError: org.elasticsearch.test.ESTestCase
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.getDeclaredMethods(Class.java:1975)
at com.carrotsearch.randomizedtesting.ClassModel$3.members(ClassModel.java:215)
at com.carrotsearch.randomizedtesting.ClassModel$3.members(ClassModel.java:212)
at com.carrotsearch.randomizedtesting.ClassModel$ModelBuilder.build(ClassModel.java:85)
at com.carrotsearch.randomizedtesting.ClassModel.methodsModel(ClassModel.java:212)
at com.carrotsearch.randomizedtesting.ClassModel.(ClassModel.java:207)
at com.carrotsearch.randomizedtesting.RandomizedRunner.(RandomizedRunner.java:329)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
at com.carrotsearch.ant.tasks.junit4.slave.SlaveMain.execute(SlaveMain.java:238)
at com.carrotsearch.ant.tasks.junit4.slave.SlaveMain.main(SlaveMain.java:354)
at com.carrotsearch.ant.tasks.junit4.slave.SlaveMainSafe.main(SlaveMainSafe.java:10)
Completed [2/2 (2!)] in 0.00s, 1 test, 1 error <<< FAILURES!

Everyone can help me ? Thanks !!!

jar1: /home/trantrungtruc/.m2/repository/org/elasticsearch/jna/4.5.1/jna-4.5.1.jar
jar2: /home/trantrungtruc/.m2/repository/net/java/dev/jna/jna/4.1.0/jna-4.1.0.jar

You are having in your classpath 2 jars. You should exclude net/java/dev/jna/jna/4.1.0/jna-4.1.0.jar from your build I think.
If you are using maven, run:

mvn dependency:tree

To see which dependency is bringing this jar and exclude it in your pom.xml.

About

Throwable #1: java.lang.NoClassDefFoundError: org.elasticsearch.test.ESTestCase

May be you did not include all the needed libs for testing? How did you build your project?

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