# Debug ES 2.0 plugin in eclipse

**URL:** <https://discuss.elastic.co/t/debug-es-2-0-plugin-in-eclipse/34911>\
**Category:** Elasticsearch\
**Created:** [November 18, 2015, 9:56am UTC](https://discuss.elastic.co/t/debug-es-2-0-plugin-in-eclipse/34911 "2015-11-18T09:56:43Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![dduft](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dduft/32/5990_2.png) [@dduft](https://discuss.elastic.co/u/dduft)\
**Post date:** [November 18, 2015, 9:56am UTC](https://discuss.elastic.co/t/debug-es-2-0-plugin-in-eclipse/34911/1 "2015-11-18T09:56:44Z")

</div>

Hi folks,

I have a jvm plugin with rest-action, which I wanted to upgrade to ES 2.0. But I was not able to debug in Eclipse anymore, how it does in former versions. The plugin simply does not get started.

I have a maven-project with ES 2.0 in the dependencies.  
My run configuration has:  
`org.elasticsearch.bootstrap.Elasticsearch` as Main-Class  
`start` as argument  
and as VM arguments:

```
 -Xms256m -Xmx1g -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=logs/heapdump.hprof -Delasticsearch -Des.foreground=yes -ea -Des.path.home=/path/to/my/plugin/ -Des.security.manager.enabled=false -Des.http.cors.enabled=true -Des.http.cors.allow-origin=*

```

In classpath, there is `JRE[J2SE-1.5], my plugin-project and maven dependencies`

Any suggestions how I get debugging and startup of my plugin done out of eclipse?

---

<div class="post-metadata">

**Author:** ![dduft](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dduft/32/5990_2.png) [@dduft](https://discuss.elastic.co/u/dduft)\
**Post date:** [November 23, 2015, 7:16am UTC](https://discuss.elastic.co/t/debug-es-2-0-plugin-in-eclipse/34911/2 "2015-11-23T07:16:19Z")

</div>

No ideas at all?  
How do you guys develop your plugins? Which IDE do you use?

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [November 23, 2015, 8:13am UTC](https://discuss.elastic.co/t/debug-es-2-0-plugin-in-eclipse/34911/3 "2015-11-23T08:13:04Z")

</div>

You should use Java 8 and not Java 5.

Start a node with settings like this

```auto
Settings settings = Settings.settingsBuilder()
                .put("cluster.name", cluster)
                .put("path.home", getHome())
                .put("plugin.types", MyPlugin.class.getName())
                .build();

```

and then

```auto
Node node = NodeBuilder.nodeBuilder().settings(settings).build();
node.start();

```

At node start, plugin is loaded and you can test it.

---

<div class="post-metadata">

**Author:** ![dduft](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dduft/32/5990_2.png) [@dduft](https://discuss.elastic.co/u/dduft)\
**Post date:** [November 23, 2015, 8:34am UTC](https://discuss.elastic.co/t/debug-es-2-0-plugin-in-eclipse/34911/4 "2015-11-23T08:34:19Z")

</div>

Hi Jörg,

Thank you for the hint. My setting was J2SE 1.5 out of Java 8?!  
I currently noticed, that Java 8 has all the 'old' J2SE included! 🙂

I will try to get my environment running with this.

---

<div class="post-metadata">

**Author:** ![dduft](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dduft/32/5990_2.png) [@dduft](https://discuss.elastic.co/u/dduft)\
**Post date:** [November 23, 2015, 10:13am UTC](https://discuss.elastic.co/t/debug-es-2-0-plugin-in-eclipse/34911/5 "2015-11-23T10:13:30Z")

</div>

So from my understanding, I have to write my own startup main-class instead of using the default  
`org.elasticsearch.bootstrap.Elasticsearch` to use `plugin-types` within the settings?  
Is wonder this is really the only way? What has changed in 2.0.0, that debugging does not work then with the versions before? Sure, ElasticsearchF has gone, but is this the reason?  
Or am I missing something else?

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [November 23, 2015, 10:27am UTC](https://discuss.elastic.co/t/debug-es-2-0-plugin-in-eclipse/34911/6 "2015-11-23T10:27:54Z")

</div>

Why a main class?

If you study the `org.elasticsearch.bootstrap.*` source code, you can see they are simply a wrapper around `NodeBuilder.nodeBuilder().settings(settings).build()` adding features that are orthogonal to ES plugins i.e. JNA, OS specific settings, CLI, logging etc.

Beside API and layout changes, ES 2.0 has added a lot more security settings which can easily get in your way while plugin testing. I recommend to just start a node for easy plugin unit testing.

---

<div class="post-metadata">

**Author:** ![dduft](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dduft/32/5990_2.png) [@dduft](https://discuss.elastic.co/u/dduft)\
**Post date:** [November 23, 2015, 10:48am UTC](https://discuss.elastic.co/t/debug-es-2-0-plugin-in-eclipse/34911/7 "2015-11-23T10:48:34Z")

</div>

So for unit testing, It is clear to me what you meant.  
But what I wanted to reach is simply upstart Elastic WITH loaded plugin in debug-mode in eclipse, like I did for former versions with main-class from `bootstrap.ElasticsearchF`.

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [November 23, 2015, 11:04am UTC](https://discuss.elastic.co/t/debug-es-2-0-plugin-in-eclipse/34911/8 "2015-11-23T11:04:08Z")

</div>

Let's recap. Have you followed the instructions?

[https://www.elastic.co/guide/en/elasticsearch/plugins/2.0/plugin-authors.html](https://www.elastic.co/guide/en/elasticsearch/plugins/2.0/plugin-authors.html)

It's hard to give useful advise to the statement "The plugin simply does not get started". Maybe you can describe the steps you made more closely so that it can be reproduced.

---

<div class="post-metadata">

**Author:** ![Uladzimir](https://avatars.discourse-cdn.com/v4/letter/u/34f0e0/32.png) [@Uladzimir](https://discuss.elastic.co/u/Uladzimir)\
**Post date:** [December 17, 2015, 11:28pm UTC](https://discuss.elastic.co/t/debug-es-2-0-plugin-in-eclipse/34911/9 "2015-12-17T23:28:16Z")

</div>

Hi dduft.

I had the same problem as you.

1. Steps to solve it:
2. Create a folder for your es\_home.
3. Configure Run/Debug configuration:
  - main class: org.elasticsearch.bootstrap.Elasticsearch
  - vm options: -Des.path.home=\<path\_to\_prev\_created\_folder\>
  - program args: start

4. Start the application. The proper structure will be created in es.path.home folder.
5. Stop the application.
6. Create a folder ${es.path.home}/plugins/\<plugin\_name\>
7. Copy your plugin-descriptor.properties in this folder.
8. Start the application in debug mode.

Now it should work, since all your sources in the classpath and plugin descriptor in the proper place.

---

<div class="post-metadata">

**Author:** ![Volodymyr\_Krupach](https://avatars.discourse-cdn.com/v4/letter/v/47e85d/32.png) [@Volodymyr\_Krupach](https://discuss.elastic.co/u/Volodymyr_Krupach)\
**Post date:** [March 31, 2016, 1:26pm UTC](https://discuss.elastic.co/t/debug-es-2-0-plugin-in-eclipse/34911/10 "2016-03-31T13:26:47Z")

</div>

Uladzimir, you saved my day! Thank you very much for the instructions!

---

<div class="post-metadata">

**Author:** ![ttjslbz](https://avatars.discourse-cdn.com/v4/letter/t/73ab20/32.png) [@ttjslbz](https://discuss.elastic.co/u/ttjslbz)\
**Post date:** [August 16, 2016, 7:25am UTC](https://discuss.elastic.co/t/debug-es-2-0-plugin-in-eclipse/34911/11 "2016-08-16T07:25:35Z")

</div>

HI Uladzimir  
I start my plugin as your step,  
But there are strange error log as below:

> er]Exception in thread "main" java.lang.IllegalStateException: running tests but failed to invoke RandomizedContext#getRandom  
> Likely root cause: java.lang.IllegalStateException: No context information for thread: Thread[id=1, name=main, state=RUNNABLE, group=main]. Is this thread running under a class com.carrotsearch.randomizedtesting.RandomizedRunner runner context? Add @RunWith(class com.carrotsearch.randomizedtesting.RandomizedRunner.class) to your test class. Make sure your code accesses random contexts within @BeforeClass and @AfterClass boundary (for example, static test class initializers are not permitted to access random contexts).  
> at com.carrotsearch.randomizedtesting.RandomizedContext.context(RandomizedContext.java:244)  
> at com.carrotsearch.randomizedtesting.RandomizedContext.current(RandomizedContext.java:151)  
> 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:483)  
> at org.elasticsearch.common.Randomness.get(Randomness.java:101)  
> at org.elasticsearch.node.internal.InternalSettingsPreparer.randomNodeName(InternalSettingsPreparer.java:205)  
> at org.elasticsearch.node.internal.InternalSettingsPreparer.finalizeSettings(InternalSettingsPreparer.java:177)  
> at org.elasticsearch.node.internal.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:106)  
> at org.elasticsearch.common.cli.CliTool.(CliTool.java:107)  
> at org.elasticsearch.common.cli.CliTool.(CliTool.java:98)  
> at org.elasticsearch.bootstrap.BootstrapCLIParser.(BootstrapCLIParser.java:49)  
> at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:247)  
> at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)  
> Refer to the log for complete error details.

---

<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:** [August 16, 2016, 12:48pm UTC](https://discuss.elastic.co/t/debug-es-2-0-plugin-in-eclipse/34911/12 "2016-08-16T12:48:02Z")

</div>

I'm not sure reviving a super old thread is the right way to get help for this, but I'll try.

You can see that error if you try and run the tests without the RandomizedRunner that we use for all of our tests. It looks like you are trying to run a main class though so I'm not sure what is up. Are your tests somehow leaking into your main classes?

---

<div class="post-metadata">

**Author:** ![ttjslbz](https://avatars.discourse-cdn.com/v4/letter/t/73ab20/32.png) [@ttjslbz](https://discuss.elastic.co/u/ttjslbz)\
**Post date:** [August 19, 2016, 4:48am UTC](https://discuss.elastic.co/t/debug-es-2-0-plugin-in-eclipse/34911/13 "2016-08-19T04:48:47Z")

</div>

Hi nik  
When i import latest elk to eclipse, Sibling project named with ":" prefix. It leads to import failed. ![](https://us1.discourse-cdn.com/elastic/original/2X/d/de04ccf68f3e0dc1bac56049770ffdd1f14e39bb.JPG)  
Is it a bug

---

<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, 10:26pm UTC](https://discuss.elastic.co/t/debug-es-2-0-plugin-in-eclipse/34911/14 "2017-07-05T22:26:47Z")

</div>


