XPages:我需要一个完整的堆栈跟踪
XPages: I need a full stacktrace
正在尝试调试此处的 XPage 应用程序。当出现 Java 异常时,XPages 在 log.nsf 中给了我很多行,当它变得有趣时,它说:
09/06/2015 17:32:53 HTTP JVM:... 81 更多
这太烦人了,至少可以说第一个真正的错误总是在堆栈跟踪的底部。
是否有我可以设置的系统参数以获得完整的堆栈跟踪?
谢谢!
最后一部分,来自log.nsf数据库:
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
已解决
var author= doc.getItemValueString("Author");
if(author) {
var editor:NotesName= session.createName(author);
adoc.replaceItemValue("Editor", editor.getCommon());
}
我添加了一个简单的测试来验证作者不为空。 Author 字段曾经出现在文档中,空 NotesName 上的 getCommon 似乎会生成异常。
我认为 e.printStackTrace();
给了你所有的东西。你单独使用这条线。它不能成为 System.out.println 的一部分,我曾尝试这样做过一次,尽管它本质上就是这样做的。
你可以把它放在你的 catch 块中。所以整个代码将是:
catch (Exception e){
e.printStackTrace();
}
话虽这么说,但我不记得有一次在堆栈跟踪的“81 多”行中有任何有用的信息。只需搜索 "Caused by..."
作为一般规则,您会希望将您的代码包围在 try/catch
块中,即使它们不是强制性的。通常认为使用日志记录来捕获错误比写入 Notes 日志更好,使用 System.out.println
and/or printStackTrace()
根据 javadoc,这些行将出现在堆栈跟踪本身中。请参见此处:http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Throwable.html#printStackTrace()
Note the presence of lines containing the characters "...". These lines indicate that the remainder of the stack trace for this exception matches the indicated number of frames from the bottom of the stack trace of the exception that was caused by this exception (the "enclosing" exception). This shorthand can greatly reduce the length of the output in the common case where a wrapped exception is thrown from same method as the "causative exception" is caught
XPages OpenLog Logger(同样的代码也在 OpenNTF Domino API 中)将错误的完整堆栈跟踪写入 OpenLog。如果您在数据库中定义了自定义错误页面,未捕获的异常也会与堆栈跟踪一起记录。 (需要自定义错误页面,以便呈现响应阶段运行,尽管是在新页面中,它允许代码创建日志。)
如果可能,它还会识别触发错误的组件。
正在尝试调试此处的 XPage 应用程序。当出现 Java 异常时,XPages 在 log.nsf 中给了我很多行,当它变得有趣时,它说:
09/06/2015 17:32:53 HTTP JVM:... 81 更多
这太烦人了,至少可以说第一个真正的错误总是在堆栈跟踪的底部。
是否有我可以设置的系统参数以获得完整的堆栈跟踪?
谢谢!
最后一部分,来自log.nsf数据库:
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
已解决
var author= doc.getItemValueString("Author");
if(author) {
var editor:NotesName= session.createName(author);
adoc.replaceItemValue("Editor", editor.getCommon());
}
我添加了一个简单的测试来验证作者不为空。 Author 字段曾经出现在文档中,空 NotesName 上的 getCommon 似乎会生成异常。
我认为 e.printStackTrace();
给了你所有的东西。你单独使用这条线。它不能成为 System.out.println 的一部分,我曾尝试这样做过一次,尽管它本质上就是这样做的。
你可以把它放在你的 catch 块中。所以整个代码将是:
catch (Exception e){
e.printStackTrace();
}
话虽这么说,但我不记得有一次在堆栈跟踪的“81 多”行中有任何有用的信息。只需搜索 "Caused by..."
作为一般规则,您会希望将您的代码包围在 try/catch
块中,即使它们不是强制性的。通常认为使用日志记录来捕获错误比写入 Notes 日志更好,使用 System.out.println
and/or printStackTrace()
根据 javadoc,这些行将出现在堆栈跟踪本身中。请参见此处:http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Throwable.html#printStackTrace()
Note the presence of lines containing the characters "...". These lines indicate that the remainder of the stack trace for this exception matches the indicated number of frames from the bottom of the stack trace of the exception that was caused by this exception (the "enclosing" exception). This shorthand can greatly reduce the length of the output in the common case where a wrapped exception is thrown from same method as the "causative exception" is caught
XPages OpenLog Logger(同样的代码也在 OpenNTF Domino API 中)将错误的完整堆栈跟踪写入 OpenLog。如果您在数据库中定义了自定义错误页面,未捕获的异常也会与堆栈跟踪一起记录。 (需要自定义错误页面,以便呈现响应阶段运行,尽管是在新页面中,它允许代码创建日志。)
如果可能,它还会识别触发错误的组件。