I am trying to do a mock testing of ES with Junit in my local environment. Simple Junit test on Eclipse IDE works but Maven run doesn't.
I am facing a Jar Hell Runtime issue.
Below are the Maven dependencies that I use.
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.elasticsearch.test</groupId>
<artifactId>framework</artifactId>
<version>5.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.7</version>
<scope>test</scope>
</dependency>
Below is the Junit class I had written using the Elasticsearch-test api
import org.elasticsearch.test.ESTestCase;
import org.junit.Test;
public class SampleTest extends ESTestCase {
@Test
public void runtTest() throws Exception{
System.out.println("HI Suman");
setUp();
}
}
I am getting the below exception running it like this
mvn clean install -Dtests.security.manager=false -Dtests.asserts=false
java.lang.RuntimeException: found jar hell in test classpath
at org.elasticsearch.bootstrap.BootstrapForTesting.<clinit>(BootstrapForTesting.java:90)
at org.elasticsearch.test.ESTestCase.<clinit>(ESTestCase.java:138)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at com.carrotsearch.randomizedtesting.RandomizedRunner$2.run(RandomizedRunner.java:585)
Caused by: java.nio.file.NoSuchFileException: C:\CodeRepo\mock-es\build\resources\test
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
at sun.nio.fs.WindowsFileAttributeViews$Basic.readAttributes(WindowsFileAttributeViews.java:53)
at sun.nio.fs.WindowsFileAttributeViews$Basic.readAttributes(WindowsFileAttributeViews.java:38)
at sun.nio.fs.WindowsFileSystemProvider.readAttributes(WindowsFileSystemProvider.java:193)
at java.nio.file.Files.readAttributes(Files.java:1737)
at java.nio.file.FileTreeWalker.getAttributes(FileTreeWalker.java:219)
at java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:276)
at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:322)
at java.nio.file.Files.walkFileTree(Files.java:2662)
at java.nio.file.Files.walkFileTree(Files.java:2742)
at org.elasticsearch.bootstrap.JarHell.checkJarHell(JarHell.java:196)
at org.elasticsearch.bootstrap.JarHell.checkJarHell(JarHell.java:88)
at org.elasticsearch.bootstrap.BootstrapForTesting.<clinit>(BootstrapForTesting.java:88)
... 4 more
It doesn't show what jars are causing the Jar Hell issue.
I tried to fix with solution provided in Java Jar hell Runtime Exception
I created the JarHell class as mentioned. But even that doesn't resolve it.