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: org/elasticsearch/plugins/ExtendedPluginsClassLoader #30774

Closed
lujqme opened this Issue May 22, 2018 · 8 comments

Comments

Projects
None yet
5 participants
@lujqme

lujqme commented May 22, 2018

Elasticsearch version (bin/elasticsearch --version):

Version: 6.2.4

Plugins installed: []

None

JVM version (java -version):

java version "10.0.1" 2018-04-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)

OS version (uname -a if on a Unix-like system):

MacBook-Pro.local 17.5.0 Darwin Kernel Version 17.5.0

Description of the problem including expected versus actual behavior:

I want to build ES and debug.ES6.2.4

Steps to reproduce:

  1. download https://github.com/elastic/elasticsearch/archive/v6.2.4.zip and unzip
  2. cd && gradle idea
  3. brew install elasticsearch
  4. https://www.elastic.co/downloads/elasticsearch and download
    https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.4.zip

copy elasticsearch-6.2.4’s modules and plugins to /usr/local/var/elasticsearch

in idea,

-Des.path.conf=/usr/local/etc/elasticsearch/
-Des.path.home=/usr/local/var/elasticsearch/
-Dlog4j2.disable.jmx=true

run elasticsearch-6.2.4/server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java

Provide logs (if relevant):

[2018-05-22T13:52:44,399][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [] fatal error in thread [main], exiting
java.lang.NoClassDefFoundError: org/elasticsearch/plugins/ExtendedPluginsClassLoader
	at org.elasticsearch.plugins.PluginsService.loadBundle(PluginsService.java:494) ~[main/:?]
	at org.elasticsearch.plugins.PluginsService.loadBundles(PluginsService.java:422) ~[main/:?]
	at org.elasticsearch.plugins.PluginsService.<init>(PluginsService.java:146) ~[main/:?]
	at org.elasticsearch.node.Node.<init>(Node.java:303) ~[main/:?]
	at org.elasticsearch.node.Node.<init>(Node.java:246) ~[main/:?]
	at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:213) ~[main/:?]
	at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:213) ~[main/:?]
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:323) ~[main/:?]
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121) ~[main/:?]
	at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112) ~[main/:?]
	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[main/:?]
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[main/:?]
	at org.elasticsearch.cli.Command.main(Command.java:90) ~[main/:?]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[main/:?]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:85) ~[main/:?]
Caused by: java.lang.ClassNotFoundException: org.elasticsearch.plugins.ExtendedPluginsClassLoader
	at jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582) ~[?:?]
	at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190) ~[?:?]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:499) ~[?:?]
	... 15 more
@ywelsch

This comment has been minimized.

Contributor

ywelsch commented May 22, 2018

hi @lujqme could you please ask your question in our forums at https://discuss.elastic.co/ ? We reserve github issues for bug reports and feature requests. Thanks. Note that https://github.com/elastic/elasticsearch/blob/v6.2.4/TESTING.asciidoc should get you started with instructions on how to build and run ES in the debugger.

@ywelsch ywelsch closed this May 22, 2018

@zhisheng17

This comment has been minimized.

zhisheng17 commented Jul 31, 2018

have the same problem, Did you solve the problem? @lujqme

@lujqme

This comment has been minimized.

lujqme commented Jul 31, 2018

@zhisheng17

This comment has been minimized.

zhisheng17 commented Jul 31, 2018

看到你是中国人,就不打英文了,毕竟菜,哈哈哈 @lujqme

你是根据下面这个文档解决的吗?

https://github.com/elastic/elasticsearch/blob/master/CONTRIBUTING.md#configuring-ides-and-running-tests

IntelliJ users can automatically configure their IDE: ./gradlew idea then File->New Project From Existing Sources. Point to the root of the source directory, select Import project from external model->Gradle, enable Use auto-import. In order to run tests directly from IDEA 2017.2 and above, it is required to disable the IDEA run launcher in order to avoid idea_rt.jar causing "jar hell". This can be achieved by adding the -Didea.no.launcher=true JVM option. Alternatively, idea.no.launcher=true can be set in the idea.properties file which can be accessed under Help > Edit Custom Properties (this will require a restart of IDEA). For IDEA 2017.3 and above, in addition to the JVM option, you will need to go to Run->Edit Configurations->...->Defaults->JUnit and verify that the Shorten command line setting is set to user-local default: none. You may also need to remove ant-javafx.jar from your classpath if that is reported as a source of jar hell.

To run an instance of elasticsearch from the source code run ./gradlew run

The Elasticsearch codebase makes heavy use of Java asserts and the test runner requires that assertions be enabled within the JVM. This can be accomplished by passing the flag -ea to the JVM on startup.

For IntelliJ, go to Run->Edit Configurations...->Defaults->JUnit->VM options and input -ea.

我也按照上面的步骤执行了。

我安装的 es 版本是 6.3.2(安装在/usr/local/下 ),源码版本也是从github拉的 6.3.2版本的源码,

jvm 运行的参数在 idea 配置的是:

-Des.path.home="/usr/local/elasticsearch-6.3.2"
-Des.path.conf="/usr/local/elasticsearch-6.3.2/config"
-Dlog4j2.disable.jmx=true
-Didea.no.launcher=true

然后再启动那个 elasticsearch.class 的时候就出现了这个错误。

[2018-07-31T15:32:05,450][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [node-0] fatal error in thread [main], exiting
java.lang.NoClassDefFoundError: org/elasticsearch/plugins/ExtendedPluginsClassLoader
    at org.elasticsearch.plugins.PluginsService.loadBundle(PluginsService.java:632) ~[main/:?]
        at org.elasticsearch.plugins.PluginsService.loadBundles(PluginsService.java:557) ~[main/:?]
        at org.elasticsearch.plugins.PluginsService.<init>(PluginsService.java:162) ~[main/:?]
        at org.elasticsearch.node.Node.<init>(Node.java:311) ~[main/:?]
        at org.elasticsearch.node.Node.<init>(Node.java:252) ~[main/:?]
        at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:213) ~[main/:?]
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:213) ~[main/:?]
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:326) ~[main/:?]
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) ~[main/:?]
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:127) ~[main/:?]
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[main/:?]
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[main/:?]
        at org.elasticsearch.cli.Command.main(Command.java:90) ~[main/:?]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[main/:?]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:86) ~[main/:?]
    Caused by: java.lang.ClassNotFoundException: org.elasticsearch.plugins.ExtendedPluginsClassLoader
        at jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582) ~[?:?]
        at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190) ~[?:?]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:499) ~[?:?]

然后自己跟了一下源码,定位分析到位置如下图:

2351533024486_ pic_hd

这个 extendedPlugins 的 size = 0 导致的问题,但是我不知道怎么解决

我之前也是按照上面说的步骤一步一步执行的。但还是出现这个问题,尴尬!

@nik9000

This comment has been minimized.

Contributor

nik9000 commented Jul 31, 2018

This is a duplicate of #31555 . I wish we had a better solution to this because every time I have to shift to IntelliJ I have to spend an hour fighting this and then remembering the issue.

@zhisheng17

This comment has been minimized.

zhisheng17 commented Aug 15, 2018

At last, I try to debug remote elasticsearch in idea

this is my blog, idea-remote-debug-elasticsearch

@whirlys

This comment has been minimized.

whirlys commented Aug 23, 2018

I found this problem is caused by IDEA. Open Edit Configurations --> check Include dependencies with Provided scope, then it works. You can find more details in my blog. 教你编译调试Elasticsearch 6.3.2源码

@zhisheng17

This comment has been minimized.

zhisheng17 commented Aug 23, 2018

good job, solve my problem @whirlys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment