AEM6.2:com.day.cq.wcm.tags.IncludeTag 错误

AEM6.2: com.day.cq.wcm.tags.IncludeTag Error

我们有 AEM6.2 节点环境,我们正在尝试访问 login.html 但出现如下错误。

搜索后我知道 java 版本可能是一个可能的原因,但我已经在这个应用程序中使用 Java 8。我没主意了。非常感谢任何建议。

14.09.2018 14:08:40.299 *ERROR* [192.156.110.11 [1536948520114] GET /content/en/account/login.html HTTP/1.1] com.day.cq.wcm.tags.IncludeTag Error while executing script defaulttopnav
org.apache.sling.api.scripting.ScriptEvaluationException:
        at org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:416)
        at org.apache.sling.scripting.core.impl.DefaultSlingScript.eval(DefaultSlingScript.java:184)
        at org.apache.sling.scripting.core.impl.DefaultSlingScript.service(DefaultSlingScript.java:491)
        at com.day.cq.wcm.tags.IncludeTag.includeScript(IncludeTag.java:178)
        at com.day.cq.wcm.tags.IncludeTag.doEndTag(IncludeTag.java:95)
        at org.apache.jsp.apps.components.navigation.topnavigation_jsp._jspService(navigation_jsp.java:329)
        at org.eclipse.jetty.io.AbstractConnection.run(AbstractConnection.java:544)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.run(QueuedThreadPool.java:555)
        at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.sling.api.SlingException:
        at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.handleJspExceptionInternal(JspServletWrapper.java:691)
        at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:608)
        at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:533)
        at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:449)
        at org.apache.sling.scripting.jsp.JspScriptEngineFactory.callJsp(JspScriptEngineFactory.java:284)
        at org.apache.sling.scripting.jsp.JspScriptEngineFactory.access0(JspScriptEngineFactory.java:102)
        at org.apache.sling.scripting.jsp.JspScriptEngineFactory$JspScriptEngine.eval(JspScriptEngineFactory.java:536)
        at org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:388)
        ... 201 common frames omitted
Caused by: java.lang.NullPointerException: null
        at org.apache.jsp.apps.components.topnavigation.defaulttopnav_jsp._jspService(defaulttopnav_jsp.java:347)
        at org.apache.sling.scripting.jsp.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
        at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:502)
        ... 206 common frames omitted

谢谢。

堆栈跟踪表明 NPE 源自 defaulttopnav_jsp.java,第 347 行。分析生成的 java 文件是可行的方法。

自 AEM 6.1 起,默认的 ClassLoader 被 FSClassLoader 取代,生成的 .java 文件不再存储在 /var/classes.

要找到 .java 文件,您需要找到 FSClassLoader 包的包 ID,然后 java 文件将位于:

[AEM_INSTALL_DIR]/crx-quickstart/launchpad/felix/bundle[BUNDLE_ID]/data/classes

还有一个 sling 插件可以帮助您从 OSGi 控制台查看生成的 java 文件。查看 these posts

从 jsp 文件编译的 servlet 抛出错误的一般解决方案是再次重新编译 jsp。

  1. 转到 system/console 并验证是否所有包都处于活动状态
  2. 转到 sling --> jsp 并重新编译所有 jsp。

如果从 otb jsp 抛出错误,这将起作用。但是,当自定义应用程序 jsp 抛出错误时,您需要通过处理错误来修复自定义 jsp 代码。

清除缓存 jsp class 文件的另一种 foolproof 方法是删除 /var/classes