我正在尝试调试存储在JCR中的JavaScript并使用Rhino运行在服务器上,通过Sightly模板语言的JavaScript UseAPI。
根据sling.properties提供的说明:
# To enable the current server side debugging in the Rhino interpreter
# set the org.apache.sling.scripting.javascript.debug property to true.
# This will open a Swing window for Rhino JavaScript debugging on the
# server platform.
当我这样做时,我可以看到Rhino的Swing窗口。但是,如果我尝试在JavaScript文件上设置断点,或者通过添加debugger;
行来触发调试器,则调试器会中断,但不会向我显示正确的文件。
类似地,如果我从Debug菜单中选择'Break on function enter',调试器将会中断,但使用'Step Into / Over / Out'似乎会跳转到代码中的随机点。
这对其他人有用吗?我正在使用org.apache.sling.scripting.javascript的v2.0.14,这似乎是最新的。
正如您在其中一条评论中已经提到的那样,看起来这个功能实际上并未实现。
Here在主要的Sightly docs上列出了以下con使用javascript使用API而不是Java Use API:
没有调试器(还)
由于rhino脚本最终编译为java类,您可以添加java.lang.System.out.println("Resource path: " + resource.getPath())
语句和日志值以进行调试,您应该看到写入crx-quickstart/logs/stdout.log
的值