JSF 脚本突然无法访问(Faces Servlet - java.lang.NullPointerException)
JSF script suddenly not accessible (Faces Servlet - java.lang.NullPointerException)
我正在使用 TomEE 7 和 JSF 2.2。
我在 commandButton 中使用了 ajax,它运行良好。但是突然(不确定应用程序中到底发生了什么变化),它不起作用,commandButton 刷新页面。检查它说的 JS 控制台:
Uncaught ReferenceError: mojarra is not defined
at HTMLInputElement.onclick
感谢 this post,我发现 JSF 脚本无法访问。所以它被加载到页面中:
<head id="j_idt3">
....
<script type="text/javascript" src="/myApp/javax.faces.resource/jsf.js.xhtml?ln=javax.faces&stage=Development"></script>
</head>
但是如果我尝试直接在浏览器中加载脚本,我会收到 500 错误,并且 TomEE 中的日志多次这样说:
21-Jun-2017 11:28:48.496 SEVERE [http-nio-8080-exec-2] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [Faces Servlet] in context with path [/myApp] threw exception [Error processing webservice request] with root cause
java.lang.NullPointerException
at org.apache.openejb.server.cxf.rs.CxfRsHttpListener.doInvoke(CxfRsHttpListener.java:245)
at org.apache.tomee.webservices.CXFJAXRSFilter.doFilter(CXFJAXRSFilter.java:94)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.openejb.server.httpd.EEFilter.doFilter(EEFilter.java:65)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108)
at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:44)
at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:44)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:522)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1102)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:788)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1485)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
所以我现在对尝试什么或进一步研究问题的方向有点迷茫。有什么想法吗?
更新
经过一些测试后,我发现我新添加的依赖项之一(我正在使用 Maven)似乎是导致错误的原因。我不知道依赖项如何干扰 JSF 库。关于如何继续隔离问题有什么建议吗?
终于,我想我明白了。 bnguyen82
处的解决方案 this question 中的答案。
我必须添加
<scope>provided</scope>
在我的 pom.xml
.
的依赖项中
我正在使用 TomEE 7 和 JSF 2.2。
我在 commandButton 中使用了 ajax,它运行良好。但是突然(不确定应用程序中到底发生了什么变化),它不起作用,commandButton 刷新页面。检查它说的 JS 控制台:
Uncaught ReferenceError: mojarra is not defined
at HTMLInputElement.onclick
感谢 this post,我发现 JSF 脚本无法访问。所以它被加载到页面中:
<head id="j_idt3">
....
<script type="text/javascript" src="/myApp/javax.faces.resource/jsf.js.xhtml?ln=javax.faces&stage=Development"></script>
</head>
但是如果我尝试直接在浏览器中加载脚本,我会收到 500 错误,并且 TomEE 中的日志多次这样说:
21-Jun-2017 11:28:48.496 SEVERE [http-nio-8080-exec-2] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [Faces Servlet] in context with path [/myApp] threw exception [Error processing webservice request] with root cause
java.lang.NullPointerException
at org.apache.openejb.server.cxf.rs.CxfRsHttpListener.doInvoke(CxfRsHttpListener.java:245)
at org.apache.tomee.webservices.CXFJAXRSFilter.doFilter(CXFJAXRSFilter.java:94)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.openejb.server.httpd.EEFilter.doFilter(EEFilter.java:65)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108)
at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:44)
at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:44)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:522)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1102)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:788)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1485)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
所以我现在对尝试什么或进一步研究问题的方向有点迷茫。有什么想法吗?
更新
经过一些测试后,我发现我新添加的依赖项之一(我正在使用 Maven)似乎是导致错误的原因。我不知道依赖项如何干扰 JSF 库。关于如何继续隔离问题有什么建议吗?
终于,我想我明白了。 bnguyen82
处的解决方案 this question 中的答案。
我必须添加
<scope>provided</scope>
在我的 pom.xml
.