# Trivial NodeBuilder Java code resulting in "jar hell" error

**URL:** <https://discuss.elastic.co/t/trivial-nodebuilder-java-code-resulting-in-jar-hell-error/34731>\
**Category:** Elasticsearch\
**Created:** [November 16, 2015, 9:00pm UTC](https://discuss.elastic.co/t/trivial-nodebuilder-java-code-resulting-in-jar-hell-error/34731 "2015-11-16T21:00:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![aliteralmind](https://avatars.discourse-cdn.com/v4/letter/a/c77e96/32.png) [@aliteralmind](https://discuss.elastic.co/u/aliteralmind)\
**Post date:** [November 16, 2015, 9:00pm UTC](https://discuss.elastic.co/t/trivial-nodebuilder-java-code-resulting-in-jar-hell-error/34731/1 "2015-11-16T21:00:10Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [November 16, 2015, 9:14pm UTC](https://discuss.elastic.co/t/trivial-nodebuilder-java-code-resulting-in-jar-hell-error/34731/2 "2015-11-16T21:14:18Z")

</div>

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

```auto
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.

---

<div class="post-metadata">

**Author:** ![aliteralmind](https://avatars.discourse-cdn.com/v4/letter/a/c77e96/32.png) [@aliteralmind](https://discuss.elastic.co/u/aliteralmind)\
**Post date:** [November 17, 2015, 5:06pm UTC](https://discuss.elastic.co/t/trivial-nodebuilder-java-code-resulting-in-jar-hell-error/34731/3 "2015-11-17T17:06:05Z")

</div>

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.

---

<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:** [November 17, 2015, 6:12pm UTC](https://discuss.elastic.co/t/trivial-nodebuilder-java-code-resulting-in-jar-hell-error/34731/4 "2015-11-17T18:12:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![reza\_sadoddin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/reza_sadoddin/32/3437_2.png) [@reza\_sadoddin](https://discuss.elastic.co/u/reza_sadoddin)\
**Post date:** [March 26, 2016, 9:28pm UTC](https://discuss.elastic.co/t/trivial-nodebuilder-java-code-resulting-in-jar-hell-error/34731/5 "2016-03-26T21:28:48Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![rahulcse](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rahulcse/32/12158_2.png) [@rahulcse](https://discuss.elastic.co/u/rahulcse)\
**Post date:** [March 28, 2016, 4:26pm UTC](https://discuss.elastic.co/t/trivial-nodebuilder-java-code-resulting-in-jar-hell-error/34731/6 "2016-03-28T16:26:39Z")

</div>

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

---

<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 5, 2017, 11:04pm UTC](https://discuss.elastic.co/t/trivial-nodebuilder-java-code-resulting-in-jar-hell-error/34731/7 "2017-07-05T23:04:36Z")

</div>


