# NPE Initializing PluginsService in ES8

**URL:** <https://discuss.elastic.co/t/npe-initializing-pluginsservice-in-es8/359667>\
**Category:** Elasticsearch\
**Created:** [May 16, 2024, 9:11pm UTC](https://discuss.elastic.co/t/npe-initializing-pluginsservice-in-es8/359667 "2024-05-16T21:11:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![buitcj](https://avatars.discourse-cdn.com/v4/letter/b/a587f6/32.png) [@buitcj](https://discuss.elastic.co/u/buitcj)\
**Post date:** [May 16, 2024, 9:11pm UTC](https://discuss.elastic.co/t/npe-initializing-pluginsservice-in-es8/359667/1 "2024-05-16T21:11:14Z")

</div>

I am trying to create a Node, which was working in ES7 and now am trying to do the same thing in ES v8.11.3. The simple code is

```auto
final Settings settings = Settings.builder()
        .put(ACTION_AUTO_CREATE_INDEX, false)
        .put(THREAD_POOL_WRITE_QUEUE_SIZE, 500)
        .put(CLIENT_TRANSPORT_PING_TIMEOUT, "20s")
        .put(TRANSPORT_TYPE, NETTY_TRANSPORT_NAME)
        .put(INDEX_STORE_TYPE, IndexModule.Type.FS.getSettingsKey())
        .put(PATH_HOME, new File(dir).getAbsolutePath())
        .put(PATH_DATA, new File(dir, "data").getAbsolutePath())
        .put(PATH_LOGS, new File(dir, "logs").getAbsolutePath())
        .put(CLUSTER_NAME, name)
        .put(NODE_NAME, name)
        .build();

Path configDir = Path.of(dir, "config");
return new Node(InternalSettingsPreparer.prepareEnvironment(settings, Collections.emptyMap(), configDir, null);

```

When this code runs, it gets to PluginsService#addServerExportersService line [elasticsearch/server/src/main/java/org/elasticsearch/plugins/PluginsService.java at v8.11.3 · elastic/elasticsearch · GitHub](https://github.com/elastic/elasticsearch/blob/v8.11.3/server/src/main/java/org/elasticsearch/plugins/PluginsService.java#L836) `PluginsService.class.getModule();` which returns an unnamed module (my understanding is this is valid) but the descriptor is null (see screenshot)

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/b/c/bc90c377bc8e5687187404e7a4c40709cbbe14e8.png)

and then gets an NPE when later calling `.exports()` on the null descriptor (see [elasticsearch/libs/core/src/main/java/org/elasticsearch/jdk/ModuleQualifiedExportsService.java at v8.11.3 · elastic/elasticsearch · GitHub](https://github.com/elastic/elasticsearch/blob/v8.11.3/libs/core/src/main/java/org/elasticsearch/jdk/ModuleQualifiedExportsService.java#L46))

Here is the call stack

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/5/b/5b94ba77b83d8fcecb2b3e7a81ffda77478108c8.png)

I don't _think_ my setup code is even relevant here, because `PluginsService.class.getModule()` is hardcoded in ES code and the module has a null descriptor. What module is expected here and what ought the descriptor be?

If the issue is somehow my setup, might someone have an example for me to create a node correctly?

---

<div class="post-metadata">

**Author:** ![buitcj](https://avatars.discourse-cdn.com/v4/letter/b/a587f6/32.png) [@buitcj](https://discuss.elastic.co/u/buitcj)\
**Post date:** [May 17, 2024, 3:41pm UTC](https://discuss.elastic.co/t/npe-initializing-pluginsservice-in-es8/359667/2 "2024-05-17T15:41:39Z")

</div>

I think I can't edit the above code anymore, but here's more complete code.

```auto
LogConfigurator.configureESLogging();
final Settings settings = Settings.builder()
    .put("path.home", "/Users/my_user")
    .build();

Path configDir = Path.of("/tmp", "config");
Node n = new Node(InternalSettingsPreparer.prepareEnvironment(settings, Collections.emptyMap(), configDir, () -> "nodename"));

```

and build.gradle has

```auto
    implementation "org.elasticsearch:elasticsearch:8.11.3"
    implementation "org.elasticsearch:elasticsearch-logging:8.11.3"
    implementation "org.apache.logging.log4j:log4j-core:2.17.1"
    implementation "org.apache.logging.log4j:log4j-api:2.17.1"

```

---

<div class="post-metadata">

**Author:** ![buitcj](https://avatars.discourse-cdn.com/v4/letter/b/a587f6/32.png) [@buitcj](https://discuss.elastic.co/u/buitcj)\
**Post date:** [May 18, 2024, 2:38pm UTC](https://discuss.elastic.co/t/npe-initializing-pluginsservice-in-es8/359667/3 "2024-05-18T14:38:38Z")

</div>

@rjernst sorry to ping you directly but I'm getting quite desperate - might you know about this issue? I see your name on this ModuleQualifiedExportsService code

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [May 20, 2024, 5:31am UTC](https://discuss.elastic.co/t/npe-initializing-pluginsservice-in-es8/359667/4 "2024-05-20T05:31:19Z")

</div>

This is a community forum manned by volunteers so it is considered rude to ping people not already involved in the thread. You also gave very little time before pinging, especially given that it was a weekend. As it is a community forum there are no SLAs or even guarantees of getting a response, so you should wait at least a few days before bumping your thread.

It may also help if you provided some additional contect around what you are doing as others might be able to chime in. Are you building a plugin? Are you trying to embed Elasticsearch into an application?

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [May 20, 2024, 9:54am UTC](https://discuss.elastic.co/t/npe-initializing-pluginsservice-in-es8/359667/5 "2024-05-20T09:54:16Z")

</div>

I don't think we'd expect this to work - it looks like you're trying to run Elasticsearch in "embedded" mode but [this hasn't been a valid approach for ~8 years](https://www.elastic.co/blog/elasticsearch-the-server). I'm somewhat surprised that this worked for you even in 7.x.

> [@buitcj](#):
>
> might someone have an example for me to create a node correctly?

The correct way to create a node is to run Elasticsearch in its own process.

---

<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:** [June 17, 2024, 9:54am UTC](https://discuss.elastic.co/t/npe-initializing-pluginsservice-in-es8/359667/6 "2024-06-17T09:54:36Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
