# NullPointerException Build.java:48

**URL:** <https://discuss.elastic.co/t/nullpointerexception-build-java-48/107830>\
**Category:** Elasticsearch\
**Created:** [November 15, 2017, 9:48pm UTC](https://discuss.elastic.co/t/nullpointerexception-build-java-48/107830 "2017-11-15T21:48:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dougbeasley](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dougbeasley/32/24293_2.png) [@dougbeasley](https://discuss.elastic.co/u/dougbeasley)\
**Post date:** [November 15, 2017, 9:48pm UTC](https://discuss.elastic.co/t/nullpointerexception-build-java-48/107830/1 "2017-11-15T21:48:48Z")

</div>

I'm having an issue with using the RestHighLevelClient with the maven-jetty-plugin.  
This NPE only manifests when running locally with mvn jetty:run  
I don't have this issue when packaging as a war and deploying to a container.

Here's the relevant stacktrace.

```
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate 
[org.elasticsearch.client.RestHighLevelClient]: Constructor threw exception; nested exception is java.lang.ExceptionInInitializerError
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:154)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:122)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:271)
... 72 more
Caused by: java.lang.ExceptionInInitializerError
at org.elasticsearch.common.logging.DeprecationLogger.<clinit>(DeprecationLogger.java:160)
at org.elasticsearch.common.ParseField.<clinit>(ParseField.java:35)
at org.elasticsearch.client.RestHighLevelClient.lambda$getDefaultNamedXContents$46(RestHighLevelClient.java:580)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.HashMap$EntrySpliterator.forEachRemaining(HashMap.java:1696)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at org.elasticsearch.client.RestHighLevelClient.getDefaultNamedXContents(RestHighLevelClient.java:581)
at org.elasticsearch.client.RestHighLevelClient.<init>(RestHighLevelClient.java:187)
at org.elasticsearch.client.RestHighLevelClient.<init>(RestHighLevelClient.java:177)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:142)
... 74 more
Caused by: java.lang.NullPointerException
at org.elasticsearch.Build.<clinit>(Build.java:48)
... 92 more

```

The problem seems to originate from around [Build.java:94](https://github.com/elastic/elasticsearch/blob/8f0685b924b9159807704ec2593b26e28105da44/core/src/main/java/org/elasticsearch/Build.java#L94)

```
static URL getElasticsearchCodebase() {
    return Build.class.getProtectionDomain().getCodeSource().getLocation();
}

```

Where the return value is null.

I'm thinking this has something to do with the classloading in jetty but I haven't been able to track down why.

---

<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:** [November 20, 2017, 1:48pm UTC](https://discuss.elastic.co/t/nullpointerexception-build-java-48/107830/2 "2017-11-20T13:48:06Z")

</div>

Thanks for the report. We opened a [pull request](https://github.com/elastic/elasticsearch/pull/27442) to address this. This will be fixed in 5.6.5.

---

<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:** [December 18, 2017, 1:48pm UTC](https://discuss.elastic.co/t/nullpointerexception-build-java-48/107830/3 "2017-12-18T13:48:10Z")

</div>

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