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:
https://github.com/elastic/elasticsearch/archive/v6.2.4.zip and unzipcd && gradle ideabrew install elasticsearchhttps://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.4.zipcopy 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
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.
have the same problem, Did you solve the problem? @lujqme
@zhisheng17 I solved the problem by https://discuss.elastic.co/t/build-from-source-but-noclassdeffounderror-extendedpluginsclassloader/132912. Hope this can help you.
看到你是中国人,就不打英文了,毕竟菜,哈哈哈 @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) ~[?:?]
然后自己跟了一下源码,定位分析到位置如下图:

这个 extendedPlugins 的 size = 0 导致的问题,但是我不知道怎么解决
我之前也是按照上面说的步骤一步一步执行的。但还是出现这个问题,尴尬!
This is a duplicate of https://github.com/elastic/elasticsearch/issues/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.
At last, I try to debug remote elasticsearch in idea
this is my blog, idea-remote-debug-elasticsearch
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源码
good job, solve my problem @whirlys
LGTM
i am using IntelliJ IDEA 2019.2.4 (Ultimate Edition) and on 7.3 branch of the elasticsearch. I am still having the issue. Some help please.
I got this problem solved by changing "compileOnly project(':libs:elasticsearch-plugin-classloader')" to "compile project(':libs:elasticsearch-plugin-classloader')" in build.gradle of the server module.
If you want to leverage IntelliJ IDEA's 'Include dependencies with "Provided" scope' to work around this issue, make sure you have 'Build and run using IntelliJ IDEA' instead of 'Build and run using Gradle(default)' on your 'Build, Execution, Deployment > Build Tools > Gradle' settings.
Most helpful comment
I found this problem is caused by IDEA. Open
Edit Configurations--> checkInclude dependencies with Provided scope, then it works. You can find more details in my blog. 教你编译调试Elasticsearch 6.3.2源码