Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoClassDefFoundError w/shaded 2.0.0.beta1 jar #12193

aleph-zero opened this issue Jul 11, 2015 · 1 comment


Copy link

commented Jul 11, 2015

I am consistently getting the following stack trace when attempting to create a node from a simple application:

--- Start Example ---
Jul 11, 2015 1:37:24 PM org.elasticsearch.node.Node <init>
INFO: [The Blank] version[2.0.0.beta1-SNAPSHOT], pid[18006], build[0b27ded/2015-07-11T20:22:54Z]
Jul 11, 2015 1:37:24 PM org.elasticsearch.node.Node <init>
INFO: [The Blank] initializing ...
Jul 11, 2015 1:37:24 PM org.elasticsearch.plugins.PluginsService <init>
INFO: [The Blank] loaded [], sites []
Jul 11, 2015 1:37:24 PM org.elasticsearch.env.NodeEnvironment maybeLogPathDetails
INFO: [The Blank] using [1] data paths, mounts [[/ (/dev/disk1)]], net usable_space [79.6gb], net total_space [464.7gb], spins? [unknown], types [hfs]
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.337 sec <<< FAILURE!
x(org.primer.stupid.TestFoo)  Time elapsed: 0.301 sec  <<< ERROR!
java.lang.NoClassDefFoundError: org/elasticsearch/common/util/concurrent/jsr166e/LongAdder
    at org.elasticsearch.common.metrics.CounterMetric.<init>(
    at org.elasticsearch.common.util.concurrent.EsAbortPolicy.<init>(
    at org.elasticsearch.common.util.concurrent.EsExecutors.newCached(
    at org.elasticsearch.threadpool.ThreadPool.rebuild(
    at org.elasticsearch.threadpool.ThreadPool.<init>(
    at org.elasticsearch.node.Node.<init>(
    at org.elasticsearch.node.NodeBuilder.node(
    at org.primer.stupid.TestFoo.x(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    at java.lang.reflect.Method.invoke(
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(
    at org.junit.runners.ParentRunner.runLeaf(
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(
    at org.junit.runners.ParentRunner$
    at org.junit.runners.ParentRunner$1.schedule(
    at org.junit.runners.ParentRunner.runChildren(
    at org.junit.runners.ParentRunner.access$000(
    at org.junit.runners.ParentRunner$2.evaluate(
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    at java.lang.reflect.Method.invoke(
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(
    at org.apache.maven.surefire.booter.ForkedBooter.main(
Caused by: java.lang.ClassNotFoundException: org.elasticsearch.common.util.concurrent.jsr166e.LongAdder
    at Method)
    at java.lang.ClassLoader.loadClass(
    at sun.misc.Launcher$AppClassLoader.loadClass(
    at java.lang.ClassLoader.loadClass(
    ... 39 more

Note that this only happens when using the shaded jar.

A simple test program to reproduce is:

public class TestFoo {

    public void x() throws Exception {

        System.out.println("--- Start Example ---");

        File home = Files.createTempDir();
        Settings settings = Settings.builder()
                .put("path.home", home.getAbsolutePath()).build();
        Node node = nodeBuilder().settings(settings).local(false).data(true).clusterName("test-cluster").node();

        System.out.println("--- Finished ---");

From what I can tell, the jsr166e classes are not getting shaded to the correct location. If I look at the shaded jar I can see the actual location of the jsr166e classes:

[ gnocchi 2.0.0.beta1-SNAPSHOT ] [ 01:42:39 ] > jar tvf elasticsearch-2.0.0.beta1-SNAPSHOT-shaded.jar | grep LongAdder
  3422 Sat Jul 11 13:23:58 PDT 2015 org/elasticsearch/common/cache/LongAdder.class

However, the pom.xml for core has this:


This comment has been minimized.

Copy link
Contributor Author

commented Jul 11, 2015

This was simply a matter of a missing line in the core/pom.xml. Adding <include>com.twitter:jsr166e</include> to the shade configuration fixed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.