0

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.

Community
  • 1
  • 1
suman35
  • 45
  • 1
  • 11
  • This should help: http://stackoverflow.com/questions/38712251/java-jar-hell-runtime-exception – Val May 03 '17 at 08:45
  • @Val As I have mentioned above I tried even with that solution but wasn't able to fix. – suman35 May 03 '17 at 09:44
  • 1
    Can you try to run this and see when the two conflicting JARs come from: `mvn dependency:tree -Dverbose -Dincludes=org.elasticsearch` – Val May 03 '17 at 09:47
  • @Val There aren't any conflicts that I see [INFO] testES:testES:jar:0.0.1-SNAPSHOT [INFO] \- org.elasticsearch.test:framework:jar:5.0.0:test [INFO] +- org.elasticsearch:elasticsearch:jar:5.0.0:test [INFO] | \- org.elasticsearch:securesm:jar:1.1:test [INFO] \- org.elasticsearch:securemock:jar:1.2:test – suman35 May 03 '17 at 10:13
  • Where did you put the JarHell class? It has to go in the src/test/java in package org.elasticsearch.bootstrap – Spirou May 19 '17 at 15:47
  • It's not actually complaining about a JAR hell, that is just the exception that is being thrown. In fact it is complaining that there are no files in the path at C:\CodeRepo\mock-es\build\resources\test while it expects something to be there. – Jaap Mar 20 '18 at 13:49

0 Answers0