6.0.0: NullPointerException at org.elasticsearch.Build.<clinit>(Build.java:49)

Hi, I'm trying to use the High Level Java REST client version 6.0.0, in an IntelliJ plugin that I'm developing, but my progress is blocked, because when trying to create an instance of RestHighLevelClient, I get

java.lang.ExceptionInInitializerError....Caused by: java.lang.NullPointerException at org.elasticsearch.Build.(Build.java:49). My scala code:

  _elastic = new RestHighLevelClient(
    RestClient.builder(
      new HttpHost("localhost", 9300, "http")))

Stack trace:

java.lang.ExceptionInInitializerError
at org.elasticsearch.common.logging.DeprecationLogger.(DeprecationLogger.java:163)
at org.elasticsearch.common.ParseField.(ParseField.java:35)
at org.elasticsearch.client.RestHighLevelClient.lambda$getDefaultNamedXContents$46(RestHighLevelClient.java:612)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.HashMap$EntrySpliterator.forEachRemaining(HashMap.java:1691)
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:613)
at org.elasticsearch.client.RestHighLevelClient.(RestHighLevelClient.java:207)
at org.elasticsearch.client.RestHighLevelClient.(RestHighLevelClient.java:192)
at org.elasticsearch.client.RestHighLevelClient.(RestHighLevelClient.java:184)
at [my plugin's stack]
at com.intellij.openapi.application.TransactionGuardImpl$6.run(TransactionGuardImpl.java:291)
at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.runNextEvent(LaterInvocator.java:326)
at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:310)
... [More IntelliJ/AWT stack]
Caused by: java.lang.NullPointerException
at org.elasticsearch.Build.(Build.java:49)
... 117 more

My best guess is it has to do with weird class loader situations, as was the case with the problem reported using it with Jetty ? I know IntelliJ plugins get their own class loader...

Any workaround in the meantime?

Are you sure that is the complete stack trace? Your thread title mentions Build, but your stack trace does not.

Sorry, forgot to include the "caused by" part which was a NullPointerException. It listed just line 49 in RestClient iirc. I can copy/paste it later when I have access to the project again...

I updated the stack trace in the original post. thanks!

This issue has been fixed on the 6.0 branch, and should be resolved in the next patch release of 6.0

I don't have any immediate work around for you (short of building your own snapshot from the git branch), but I'm confident we'll have a fixed version available in the not-too-distant future.

Awesome, thanks!

This fix is available in 6.0.1 now.

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