# Java Transport Client 5.4.1 NullPointerException

**URL:** <https://discuss.elastic.co/t/java-transport-client-5-4-1-nullpointerexception/88590>\
**Category:** Elasticsearch\
**Created:** [June 7, 2017, 1:17pm UTC](https://discuss.elastic.co/t/java-transport-client-5-4-1-nullpointerexception/88590 "2017-06-07T13:17:12Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![aszac](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@aszac](https://discuss.elastic.co/u/aszac)\
**Post date:** [June 7, 2017, 1:17pm UTC](https://discuss.elastic.co/t/java-transport-client-5-4-1-nullpointerexception/88590/1 "2017-06-07T13:17:12Z")

</div>

Hello,

I am trying to upgrade my service from Elasticsearch 1.4 to Elasticsearch 5.4.1. It run without issues on Centos 6.8, but after the upgrade I am getting the following error:

Exception in thread "main" java.lang.ExceptionInInitializerError  
at org.elasticsearch.common.logging.DeprecationLogger.(DeprecationLogger.java:138)  
at org.elasticsearch.common.xcontent.support.AbstractXContentParser.(AbstractXContentParser.java:57)  
at org.elasticsearch.common.xcontent.json.JsonXContentParser.(JsonXContentParser.java:44)  
at org.elasticsearch.common.xcontent.json.JsonXContent.createParser(JsonXContent.java:103)  
at org.elasticsearch.common.settings.Setting.parseableStringToList(Setting.java:848)  
at org.elasticsearch.common.settings.Setting.lambda$listSetting$27(Setting.java:802)  
at org.elasticsearch.common.settings.Setting.listSetting(Setting.java:807)  
at org.elasticsearch.common.settings.Setting.listSetting(Setting.java:802)  
at org.elasticsearch.common.network.NetworkService.(NetworkService.java:50)  
at org.elasticsearch.client.transport.TransportClient.newPluginService(TransportClient.java:98)  
at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:126)  
at org.elasticsearch.client.transport.TransportClient.(TransportClient.java:268)  
at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:127)  
at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:113)  
at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:103)  
...  
Caused by: java.lang.NullPointerException  
at org.elasticsearch.Build.(Build.java:51)  
... 24 more

What could be the cause of this problem?

Thanks,

Agnieszka

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 7, 2017, 1:46pm UTC](https://discuss.elastic.co/t/java-transport-client-5-4-1-nullpointerexception/88590/2 "2017-06-07T13:46:49Z")

</div>

Never saw that. It sounds like the manifest file is not there.  
My guess is that you still have an old elasticsearch jar somewhere in your class path.

---

<div class="post-metadata">

**Author:** ![aszac](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@aszac](https://discuss.elastic.co/u/aszac)\
**Post date:** [June 7, 2017, 2:42pm UTC](https://discuss.elastic.co/t/java-transport-client-5-4-1-nullpointerexception/88590/3 "2017-06-07T14:42:02Z")

</div>

My class path has elasticsearch-5.4.1.jar and transport-5.4.1.jar and I do have a manifest file present.

---

<div class="post-metadata">

**Author:** ![aszac](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@aszac](https://discuss.elastic.co/u/aszac)\
**Post date:** [June 7, 2017, 3:20pm UTC](https://discuss.elastic.co/t/java-transport-client-5-4-1-nullpointerexception/88590/4 "2017-06-07T15:20:57Z")

</div>

There has been a thread about this issue already, but apparently it has been resolved: [ES 5.3 and Java-API 5.3.0 \> java.lang.NullPointerException?](https://discuss.elastic.co/t/es-5-3-and-java-api-5-3-0-java-lang-nullpointerexception/81287/4) in Elasticsearch 5.3. However, I am still seeing that issue the the latest version (5.4.1 and 5.4.0).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 7, 2017, 4:34pm UTC](https://discuss.elastic.co/t/java-transport-client-5-4-1-nullpointerexception/88590/5 "2017-06-07T16:34:00Z")

</div>

@jasontedor WDYT?

---

<div class="post-metadata">

**Author:** ![jcalonso](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jcalonso/32/18912_2.png) [@jcalonso](https://discuss.elastic.co/u/jcalonso)\
**Post date:** [June 8, 2017, 3:17pm UTC](https://discuss.elastic.co/t/java-transport-client-5-4-1-nullpointerexception/88590/6 "2017-06-08T15:17:19Z")

</div>

To complement the information on this issue, we found that:

> <https://github.com/elastic/elasticsearch/blob/v5.4.1/core/src/main/java/org/elasticsearch/Build.java#L49>

Returns a `JarInputStream` with man = null (and most of the other properties are null) possibly because is not being able to read the MANIFEST file.

To verify that there was a Manifest file we manually uncompress the `elasticsearch-5.4.1.jar` file and the file seems to be correct.

Any ideas what can cause this behaviour?

If it helps:  
OS: Centos 6.8  
openjdk version "1.8.0\_121"  
OpenJDK Runtime Environment (build 1.8.0\_121-b13)  
OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)

---

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [June 8, 2017, 7:18pm UTC](https://discuss.elastic.co/t/java-transport-client-5-4-1-nullpointerexception/88590/7 "2017-06-08T19:18:22Z")

</div>

How are you starting elasticsearch?

---

<div class="post-metadata">

**Author:** ![aszac](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@aszac](https://discuss.elastic.co/u/aszac)\
**Post date:** [June 8, 2017, 7:37pm UTC](https://discuss.elastic.co/t/java-transport-client-5-4-1-nullpointerexception/88590/8 "2017-06-08T19:37:35Z")

</div>

We are starting the elasticsearch with the following config:

[cluster.name](http://cluster.name): "elasticsearch"  
node.master: true  
node.data: true  
path.data: /var/log/elasticsearch/  
path.logs: /var/log/elasticsearch/  
[node.name](http://node.name): "test"

The command is:  
/usr/share/elasticsearch/bin/elasticsearch -Epath.conf=/etc/elasticsearch/elasticsearch.yml

---

<div class="post-metadata">

**Author:** ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)\
**Post date:** [June 11, 2017, 12:00pm UTC](https://discuss.elastic.co/t/java-transport-client-5-4-1-nullpointerexception/88590/9 "2017-06-11T12:00:39Z")

</div>

How are you starting the transport client, what is it hosted inside of?

---

<div class="post-metadata">

**Author:** ![jcalonso](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jcalonso/32/18912_2.png) [@jcalonso](https://discuss.elastic.co/u/jcalonso)\
**Post date:** [June 12, 2017, 6:04pm UTC](https://discuss.elastic.co/t/java-transport-client-5-4-1-nullpointerexception/88590/10 "2017-06-12T18:04:25Z")

</div>

Hi jasontedor, here is a snippet:

```
 val s = Settings.builder()
    .put("cluster.name", clusterName)
    .build()

  val client = new PreBuiltTransportClient(s)
  nodes.asScala.foreach { node =>
    client.addTransportAddress(new InetSocketTransportAddress(node))
  }

```

The exception occurs on the instantiation of the `PreBuiltTransportClient`

We found that our `elasticsearch-5.4.1.jar` has a different sha1 hash from the one published on maven central.

We are investigating this issue, but I believe this is the reason why it cannot read the manifest file.

---

<div class="post-metadata">

**Author:** ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)\
**Post date:** [June 13, 2017, 3:51am UTC](https://discuss.elastic.co/t/java-transport-client-5-4-1-nullpointerexception/88590/11 "2017-06-13T03:51:17Z")

</div>

That would indeed be a problem.

---

<div class="post-metadata">

**Author:** ![billnbell](https://avatars.discourse-cdn.com/v4/letter/b/eb8c5e/32.png) [@billnbell](https://discuss.elastic.co/u/billnbell)\
**Post date:** [June 19, 2017, 4:59pm UTC](https://discuss.elastic.co/t/java-transport-client-5-4-1-nullpointerexception/88590/12 "2017-06-19T16:59:50Z")

</div>

Has this been fixed?

---

<div class="post-metadata">

**Author:** ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)\
**Post date:** [June 19, 2017, 7:01pm UTC](https://discuss.elastic.co/t/java-transport-client-5-4-1-nullpointerexception/88590/13 "2017-06-19T19:01:55Z")

</div>

@billnbell Is what fixed? The issue reported here for this user was caused by them not using an official distribution.

---

<div class="post-metadata">

**Author:** ![jcalonso](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jcalonso/32/18912_2.png) [@jcalonso](https://discuss.elastic.co/u/jcalonso)\
**Post date:** [June 20, 2017, 7:55pm UTC](https://discuss.elastic.co/t/java-transport-client-5-4-1-nullpointerexception/88590/14 "2017-06-20T19:55:12Z")

</div>

@jasontedor we are using the official distribution of Elasticsearch.  
After more investigation we found that the issue was in our CI system at build time when it create rpms for our Scala services.

Apparently there is some [jar repackaging happening on Centos](https://www.redhat.com/archives/fedora-devel-java-list/2008-September/msg00040.html) that changes the sha1 sums of the jar files and in the case of elasticsearch-5.4.1.jar when you try to instantiate a `PreBuiltTransportClient` it does some validation using the MANIFEST file and this was failing because of the different sha1sum.

To fix this we had to explicit remove the repackaging in the spec files generated by sbt and maven.

For sbt (Build.sbt):

```auto
import com.typesafe.sbt.packager.rpm.RpmPlugin.Names
val script =
  """%define __os_install_post \
%{_rpmconfigdir}/brp-compress \
%{!? __debug_package:%{_rpmconfigdir}/brp-strip %{__ strip}} \
%{_rpmconfigdir}/brp-strip-static-archive %{__strip} \
%{_rpmconfigdir}/brp-strip-comment-note %{ __strip} %{__ objdump} \
%{nil}
"""
...

maintainerScripts in Rpm += (Names.Pre -> ((maintainerScripts in Rpm).value.getOrElse(Names.Pre, Nil) :+ script))

```

For maven (inside the rpm-maven-plugin configuration node) :

```auto
                            <defineStatements>
                                <defineStatement>_unpackaged_files_terminate_build 0</defineStatement>
                                <defineStatement>__os_install_post \
%{_rpmconfigdir}/brp-compress \
%{!? __debug_package:%{_rpmconfigdir}/brp-strip %{__ strip}} \
%{_rpmconfigdir}/brp-strip-static-archive %{__strip} \
%{_rpmconfigdir}/brp-strip-comment-note %{ __strip} %{__ objdump} \
%{nil}
                                </defineStatement>
</defineStatements>

```

---

<div class="post-metadata">

**Author:** ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)\
**Post date:** [June 21, 2017, 10:24am UTC](https://discuss.elastic.co/t/java-transport-client-5-4-1-nullpointerexception/88590/15 "2017-06-21T10:24:45Z")

</div>

> [@jcalonso](#):
>
> we are using the official distribution of Elasticsearch.

I'm glad you've found the issue. I want to be clear about something for others that are following this thread. A repackaged distribution is not an official distribution, and we do not support repackaged distributions.

---

<div class="post-metadata">

**Author:** ![jcalonso](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jcalonso/32/18912_2.png) [@jcalonso](https://discuss.elastic.co/u/jcalonso)\
**Post date:** [June 21, 2017, 10:39am UTC](https://discuss.elastic.co/t/java-transport-client-5-4-1-nullpointerexception/88590/16 "2017-06-21T10:39:00Z")

</div>

Thanks the help and clarification @jasontedor! 🙂

---

<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 19, 2017, 10:39am UTC](https://discuss.elastic.co/t/java-transport-client-5-4-1-nullpointerexception/88590/17 "2017-07-19T10:39:21Z")

</div>

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