突然无法访问JSF脚本(Faces Servlet - java.lang.NullPointerException)

时间:2017-06-21 09:57:47

标签: jsf-2.2 tomee-7

我正在使用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&amp;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库。关于如何继续隔离问题的任何建议?

1 个答案:

答案 0 :(得分:0)

最后,我想我明白了。在this questionbnguyen82回答中的解决方案。 我不得不添加

<scope>provided</scope>

pom.xml中的依赖项内部。