I'm trying the elasticsearch Java API. And I got this error :
java.lang.NullPointerException
at java.io.Reader.<init>(Reader.java:78)
at java.io.InputStreamReader.<init>(InputStreamReader.java:113)
at org.elasticsearch.node.internal.InternalSettingsPreparer.randomNodeName(InternalSettingsPreparer.java:198)
at org.elasticsearch.node.internal.InternalSettingsPreparer.finalizeSettings(InternalSettingsPreparer.java:177)
at org.elasticsearch.node.internal.InternalSettingsPreparer.prepareSettings(InternalSettingsPreparer.java:64)
at org.elasticsearch.client.transport.TransportClient$Builder.build(TransportClient.java:119)
at TryElastic.main(TryElastic.java:64)
So, how can I get the error cause? It only said that it's an null pointer error. The only file that I can open and edit is my file "TryElastic.java". I want to know, what cause java.io.Reader error. I need your suggest, Thanks...
If you look at the source of the method which probably causes the NPE
you see that it is trying to load a resource /config/names.txt
which obviously returns null and triggers the NPE in the Reader constructor. (Stracktrace line numbers do not match exactly due to different versions used).
Unfortunately Elastic does not check the resource stream - it really should raise an own exception with a better error message.
So to solve the problem you should check if that resource is available in your installation.