I've test my apps using elasticsearch with very simple line of code. Like this :
Node node = nodeBuilder()
.settings(Settings.settingsBuilder().put("cluster.name", "elasticsearch").put("clster.transport.sniff", true).put("path.home", "/home/kenny/Program/Java/elastic"$
.node();
But I got error like this :
Exception in thread "main" 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.prepareEnvironment(InternalSettingsPreparer.java:101)
at org.elasticsearch.node.Node.<init>(Node.java:128)
at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:145)
at org.elasticsearch.node.NodeBuilder.node(NodeBuilder.java:152)
at TryElastic.main(TryElastic.java:56)
I don't know how to solve this problem, I've try and looking for the solution. Line 56 at error log, refer to ".node()" method above. So, dou you have suggestion or there are something that I've to add in my code
Thanks.....
The only way this can happen is due to a misconfiguration of path.home.
When Elasticsearch tries to generate a random node name for your instance, it looks for a file at {path.home}/config/names.txt
If the file cannot be found, you'll get a (rather unfriendly and unhelpful) NullPointerException.
So the solution is to check that "/home/kenny/Program/Java/elastic" is really the top-level of an ES installation.
See here for docs on the correct directory layout.
Related
While compiling an opensource project, I encounter a problem with a Maven plugin that fails.
And I would like to open an issue about its problem. To be helpful to those who will search to solve it, I would like to explain how it might happen.
Execution default of goal pl.project13.maven:git-commit-id-plugin:4.0.3:revision failed. (pl.project13.maven:git-commit-id-plugin:4.0.3:revision:default:initialize)
org.apache.maven.plugin.PluginExecutionException: Execution default of goal pl.project13.maven:git-commit-id-plugin:4.0.3:revision failed.
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:148)
at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:332)
at org.eclipse.m2e.core.internal.embedder.MavenImpl.lambda$8(MavenImpl.java:1380)
at [...]
Caused by: java.lang.NullPointerException
at pl.project13.maven.git.GitCommitIdMojo.execute(GitCommitIdMojo.java:441)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
... 30 more
For that, I've red the involved line that causes the NullPointerException on its Git repository.
The content of the line 441 of GitCommitIdMojo.java is :
List<MavenProject> sortedProjects =
Optional.ofNullable(session.getProjectDependencyGraph())
.map(graph -> graph.getSortedProjects())
.orElseGet(() -> {
log.warn("Maven's dependency graph is null. Assuming project is the only one executed.");
return Collections.singletonList(session.getCurrentProject());
});
But I'm not so experienced with Optional and other inline functions. And I wonder from where the NullPointerException is really coming. I have no way to test it in Live, so I can only guess.
I've checked on the source file : session is a required attribute. It shouldn't be null.
I believe that the Optional.ofNullable(...) protects the content inside parenthesis and that the NullPointerException isn't coming from here.
But when entering the .orElseGet(...) part of the expression, it might fail on Collections.singletonList(session.getCurrentProject()) where session.getCurrentProject() would return null.
Am I right?
What other parts of this statement could lead to a NullPointerException under what conditions?
You're not looking at the right version of the code. The maven-error refers to 4.0.3 of git-commit-id-plugin, but the code you're displaying comes from the master branch, which is at 4.0.4-SNAPSHOT.
This is line 441 in version 4.0.3:
List sortedProjects = session.getProjectDependencyGraph().getSortedProjects();
The NullPointer can come from any of the three parts.
I am facing this weird issue. I was working on a project, I had written some code to generate and XML using XML parser. The thing is when i run the code when on my local system, it runs fine. But when i deploy the code on to the environment, i doesn't. I am suspecting some sort of JAR thing. But i cant quite place it.
XML-22900: (Fatal Error) An internal error condition occurred.
Caused by: java.lang.NullPointerException
at oracle.xml.xslt.XSLEventHandler.characters(XSLEventHandler.java:866)
at oracle.xml.xslt.XSLTContext.reportNode(XSLTContext.java:426)
at oracle.xml.xslt.XSLTContext.reportNode(XSLTContext.java:390)
at oracle.xml.xslt.XSLTContext.reportNode(XSLTContext.java:390)
at oracle.xml.xslt.XSLTContext.reportNode(XSLTContext.java:1340)
at oracle.xml.xslt.XSLCopyOf.processAction(XSLCopyOf.java:136)
at oracle.xml.xslt.XSLNode.processChildren(XSLNode.java:480)
at oracle.xml.xslt.XSLTemplate.processAction(XSLTemplate.java:205)
at oracle.xml.xslt.XSLStylesheet.execute(XSLStylesheet.java:581)
at oracle.xml.xslt.XSLStylesheet.execute(XSLStylesheet.java:548)
at oracle.xml.xslt.XSLProcessor.processXSL(XSLProcessor.java:339)
at oracle.xml.jaxp.JXTransformer.transform(JXTransformer.java:454)
... 3 more
The input is the same, the code is the same, not sure what else i can provide, if you do need some more info let me know.
I had the same error. The error seems to be related to the transformer being used. Try using the Xalan factory.
TransformerFactory factory = new org.apache.xalan.processor.TransformerFactoryImpl();
i am fairly new in java and currently working in Struts 1.3. My question is more related with java.
Following is the scenario and i am not sure regarding the best approach to be followed.
I want to make a error reporting functionality in my project where in I'm copying stacktrace and inserting it in the database's table say "errorlog" table with type of exception,date, user etc and other fields. But now what i have to do is :
I have to identify the package name, file, method and line number in which the exception occurred with the help of server logs that i have when exception occurs.
But the problem is that the log gives you the exception, file and the line number but it also contains errors that are not in my packages as in HttpServlet.service(HttpServlet.java:710) etc given below:
java.lang.NullPointerException
com.candidate.query.CandSearchAction.execute(CandSearchAction.java:34)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
org.apache.struts.action.RequestProcessor.proc ess(RequestProcessor.java:274)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
In above case, i got a null pointer exception in my CandSearchAction.java line number 34.
Now i want to know how to differentiate or extract only the line that points to my java/jsp file, so that i can filter them accordingly.
Can anyone please help regarding this situation or how to approach this problem.. is there any library that i can use or anything that could help me.
Waiting for a response that would help me.
If your code follows the same basic structure you used in your example, you could parse the stack trace for anything starting with 1 of your package names and only use those lines.
We are getting a mustache play error in production (amazon linux EC2 AMI) but not in development (MACs) and we have tried upgrading the jvm, using the jdk instead, and changing from a tomcat deploy model to match our development environments as much as possible but nothing is working. Please any help would be greatly appreciated. We have lots of shared code in java and javascript using mustache and it would be a big deal to rewrite everything if we had to ditch mustache on the java side.
20:48:52,403 ERROR ~
#6al2dd0po
Internal Server Error (500) for request GET /mystuff/people
Execution exception (In {module:mustache-0.2}/app/play/modules/mustache/MustacheTags.java around line 32)
NullPointerException occured : null
play.exceptions.JavaExecutionException
at play.templates.BaseTemplate.throwException(BaseTemplate.java:90)
at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:257)
at play.templates.Template.render(Template.java:26)
at play.templates.GroovyTemplate.render(GroovyTemplate.java:187)
at play.mvc.results.RenderTemplate.<init>(RenderTemplate.java:24)
at play.mvc.Controller.renderTemplate(Controller.java:660)
at play.mvc.Controller.renderTemplate(Controller.java:640)
at play.mvc.Controller.render(Controller.java:695)
at controllers.MyStuff.people(MyStuff.java:183)
at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:548)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:502)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:478)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:473)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:161)
at Invocation.HTTP Request(Play!)
Caused by: java.lang.NullPointerException
at play.modules.mustache.MustacheTags._template(MustacheTags.java:32)
at play.modules.mustache.MustacheTags$_template.call(Unknown Source)
at /app/views/User/people.html.(line:22)
at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:232)
... 13 more
Seems the issue is with the threadlocal. In Prod as per my logs, the session gets initialized with the main thread.
[2012-06-30 18:35:38,102] INFO 10097[**main**] - Mustache module initialized
However, MustacheTag tries to access with various thread like this during request.
[2012-06-30 17:48:44,669] INFO 66048[**play-thread-1**] - [{module:mustache-0.2}/app/play/modules/mustache/MustacheTags.java:46] _meta() :: MustachePlugin.session():null
So I changed the implementation of MustachePlugin like this.Changed line commented out:
//private static ThreadLocal<MustacheSession> session_ = new ThreadLocal<MustacheSession>();
private static MustacheSession _session = null;
public static MustacheSession session(){
//return session_.get();
return _session;
}
public void onConfigurationRead(){
// some code
_session = new MustacheSession(compiler, root);
// some code
}
And it is working fine now in prod mode! I see no reason why it should have been in a ThreadLocal in the first place as the session gets initialized at startup!
your issue is difficult to reproduce so i'll give few pointers here. you have tried to eliminate of issue being env issue. so other possible issues could be
data issue: many times reason for production issue is usually difference in actual data and test data. check if its data issue which is casuing NPE.
code issue: Is there something at people.html.(line:22) causing issue. first try removing / altering that to check if thats causing issue. Or can you get source code of mustache (exact version which you are using) and see what object its trying to create and where its failing.
Properties file for different environments: do you have different proprties file for each env? If yes, have u missed on any property for prod env?
You have a NullPointerException on MustacheTags.java at line 32.
This means that you are probably calling a method of the Mustache library and passing a null value.
Try logging all the parameters you transfer to this method (MyStuff.java line 183?).
You can look at the source code of MustacheTags here, it might help you understand what values you are passing and what should be passed.
we are getting this error at the end of running application. I search in google buti don't know what cause this error and what this means. What to do and how to solve it?
i even don't know what raise this exception...
Exception breakpoint occurred at line 145 of EventDispatchThread.java.
java.lang.NullPointerException:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at oracle.jbo.uicli.jui.JUTableBinding$JUTableModel$2.run(JUTableBinding.java:1209)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Don't know what kind of searches you have performed on Google. I would suggest looking up each error (or rather each class where error occurs). Starting from the beginning as subsequent errors may be a due to error propagation. Two searches for EventDispatchThread and JUTableBinding.java may provide some insight at what went wrong.
http://www.docjar.org/docs/api/java/awt/EventDispatchThread.html
It seems that this class deals with AWT components ("takes events off the EventQueue and dispatches them to the appropriate AWT components")
For the JUTableBinding.java there are quite a few pages that say about NullPointerException
https://forums.oracle.com/forums/thread.jspa?threadID=515213
https://forums.oracle.com/forums/thread.jspa?threadID=2343921
https://kr.forums.oracle.com/forums/thread.jspa?threadID=503593
Some of them say that the problem may be with jdk version (seems 1.6 and above throw errors). I would assume that may be the case. Try to recompile using earlier versions of jdk and check whether error is still there. If it is not this then we will investigate further.
"I've looked into the code and found out that JUTableBinding.JUTableModel calls
mScrollUnit = control.getScrollableUnitIncrement(null,
SwingConstants.VERTICAL, 0);
(Line 947)
This was okay in Java 5, since JTable's getScrollableUnitIncrement just returned the row height."
"I changed the line to:
mScrollUnit = control.getScrollableUnitIncrement(
control.getVisibleRect(), SwingConstants.VERTICAL, 0);
and everything works fine on Java 6..."
Hope it helps.