Trying to debug an XPages application here. When there's a Java exception, XPages gives me a lot of lines in log.nsf and just when it gets interesting it says:
09/06/2015 17:32:53 HTTP JVM: ... 81 more
This is so annoying, to say the least The first real error is always in the bottom part of the stacktrace.
Is there a system parameter that I can set in order to get a full stacktrace?
Thanks!
The last part, from the log.nsf database:
09/06/2015 17:31:15 HTTP JVM: Caused by:
09/06/2015 17:31:15 HTTP JVM: java.lang.NullPointerException
09/06/2015 17:31:15 HTTP JVM: at org.openntf.domino.utils.DominoUtils.isHierarchicalName(DominoUtils.java:412)
09/06/2015 17:31:15 HTTP JVM: at org.openntf.arpa.NamePartsMap.parse(NamePartsMap.java:545)
09/06/2015 17:31:15 HTTP JVM: at org.openntf.arpa.NamePartsMap.parse(NamePartsMap.java:532)
09/06/2015 17:31:15 HTTP JVM: at org.openntf.arpa.NamePartsMap.<init>(NamePartsMap.java:103)
09/06/2015 17:31:15 HTTP JVM: at org.openntf.domino.impl.Name.parse(Name.java:1045)
09/06/2015 17:31:15 HTTP JVM: at org.openntf.domino.impl.Name.parse(Name.java:1060)
09/06/2015 17:31:15 HTTP JVM: at org.openntf.domino.impl.Name.getCommon(Name.java:593)
09/06/2015 17:31:15 HTTP JVM: ... 81 more
Solved
var author= doc.getItemValueString("Author");
if(author) {
var editor:NotesName= session.createName(author);
adoc.replaceItemValue("Editor", editor.getCommon());
}
I added a simple test to verify that author isn't empty. The Author field used to be present in the document, and a getCommon on an empty NotesName seems to generate the exception.
I think that
e.printStackTrace();
gives you the whole thing. You use this line stand alone. It can't be part of a System.out.println, which I tried to do once, although that is what it does essentially.You would put this in your catch block. So the entire code would be:
With that being said, I can't rememember a single time where anything useful is in those "81 more" lines of the stack trace. Just search for the "Caused by..."
As a general rule, you will want to surround your code in
try/catch
blocks even if they aren't manditory. It is generally considered better to use logging to trap errors than to write to the Notes log, usingSystem.out.println
and/orprintStackTrace()