Trivial NodeBuilder Java code resulting in "jar hell" error

This code

package threepieces.esonly;

import org.elasticsearch.client.Client;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.node.NodeBuilder;

public class TrivialNode {

    public static void main(String[] argsIgnored) {
        Settings settings = Settings.settingsBuilder()
                .put("path.home", "/Applications/elasticsearch-2.0.0/")
                .put("cluster.name", "epsteinj-elasticsearch-local")
                .put("http.enabled", true)
                .put("index.number_of_shards", 1)
                .put("index.number_of_replicas", 1).build();

        Client client = NodeBuilder.nodeBuilder().settings(settings).client(true).node().client();
    }
}

Causes this error

Exception in thread "main" java.lang.IllegalStateException: failed to load bundle [file:/Applications/elasticsearch-2.0.0/plugins/license/license-2.0.0.jar, file:/Applications/elasticsearch-2.0.0/plugins/license/license-core-2.0.0.jar, file:/Applications/elasticsearch-2.0.0/plugins/license/license-plugin-api-2.0.0.jar, file:/Applications/elasticsearch-2.0.0/plugins/marvel-agent/marvel-agent-2.0.0.jar] due to jar hell
    at org.elasticsearch.plugins.PluginsService.loadBundles(PluginsService.java:342)
    at org.elasticsearch.plugins.PluginsService.(PluginsService.java:113)
    at org.elasticsearch.node.Node.(Node.java:144)
    at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:145)
    at org.elasticsearch.node.NodeBuilder.node(NodeBuilder.java:152)
    at threepieces.esonly.TrivialNode.main(TrivialNode.java:17)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: java.lang.IllegalStateException: jar hell!
class: jdk.packager.services.UserJvmOptionsService
jar1: /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/ant-javafx.jar
jar2: /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/packager.jar
    at org.elasticsearch.bootstrap.JarHell.checkClass(JarHell.java:267)
    at org.elasticsearch.bootstrap.JarHell.checkJarHell(JarHell.java:185)
    at org.elasticsearch.plugins.PluginsService.loadBundles(PluginsService.java:340)
    ... 10 more

Any ideas why?

You've got a class defined in two places on the classpath:

jar1: /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/ant-javafx.jar
jar2: /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/packager.jar

This has caused tons of subtle issues in the past so in 2.0 we try to detect when it happens and be paranoid about it.

I saw a jar-hell related bug in another ElasticSearch forum, so I assumed it was a related bug and didn't look carefully enough at the error message.

I've removed ant-javafx.jar from the JDK, and it now works. But it honestly seems like an odd thing to have to do--alter some files from the default installation of the Oracle JDK. But for now, I don't use JavaFX anywhere, so hopefully this won't cause other problems.

Thanks for you help.

You should not touch the JDK installation itself but just change how IntelliJ declares it. By default IntelliJ adds all those jars when you define the Java SDK. Change that on IntelliJ side.

I have encountered a similar jar hell problem, but with two different jar files :
jar 1: jasper-runtime-5.5.15.jar
jar 2 : jasper-compiler-5.5.15.jar

Do you have any solution to this problem?

Thanks,

You need to get rid of one jar to avoid this problem.
You can use maven to stop one jar coming to your project.