我在访问应用程序的任何视图(xhtml)时遇到问题。javax.enterprise.context.ContextNotActiveException:如果我设置了错误页面标记,那么在访问任何视图时都会发生以下异常。应用程序工作正常,但在访问任何视图时都会发生异常。如果我删除错误页面标记的配置,则不会发生异常。我使用的是primefaces 4+WAS 8.5.5.1(MyFaces+OpenWebBeans)。我将感谢的任何帮助
<!-- JSF Servlet -->
<servlet>
<servlet-name>facesServlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>facesServlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<!-- Ominifaces -->
<filter>
<filter-name>facesExceptionFilter</filter-name>
<filter-class>org.omnifaces.filter.FacesExceptionFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>facesExceptionFilter</filter-name>
<servlet-name>facesServlet</servlet-name>
</filter-mapping>
<!-- error -->
<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>/paginas/erro/sessaoExpirada.xhtml</location>
</error-page>
<error-page>
<exception-type>java.lang.RuntimeException</exception-type>
<location>/paginas/erro/erro500.xhtml</location>
</error-page>
编辑:我注意到只有在设置标记错误代码时才会出现错误。
<error-page>
<error-code>500</error-code>
<location>/paginas/erro/erro500.xhtml</location>
</error-page>
如果我只设置了异常类型标记,则不会出现问题。
<error-page>
<exception-type>java.lang.RuntimeException</exception-type>
<location>/paginas/erro/erro500.xhtml</location>
</error-page>
下面是堆栈跟踪
00000082 ServletWrappe E com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0014E: Uncaught service() exception root cause facesServlet: javax.servlet.ServletException: WebBeans context with scope type annotation @RequestScoped does not exist within current thread
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:221)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1230)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:779)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:79)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:960)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1064)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:1385)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:194)
at com.ibm.ws.webcontainer.webapp.WebApp.sendError(WebApp.java:3328)
at com.ibm.ws.webcontainer.webapp.WebApp.handleException(WebApp.java:3856)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3837)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:976)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:200)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:459)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:526)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:312)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:88)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1862)
Caused by: javax.enterprise.context.ContextNotActiveException: WebBeans context with scope type annotation @RequestScoped does not exist within current thread
at org.apache.webbeans.container.BeanManagerImpl.getContext(BeanManagerImpl.java:321)
at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.getContextualInstance(NormalScopedBeanInterceptorHandler.java:124)
at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.invoke(NormalScopedBeanInterceptorHandler.java:95)
at org.apache.webbeans.conversation.ConversationImpl_$$_javassist_4.isTransient(ConversationImpl_$$_javassist_4.java)
at org.apache.webbeans.jsf.WebBeansPhaseListener.beforePhase(WebBeansPhaseListener.java:93)
at org.apache.myfaces.lifecycle.PhaseListenerManager.informPhaseListenersBefore(PhaseListenerManager.java:76)
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:160)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:119)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:189)
*编辑2*如果我删除404错误页面定义,则不会引发异常
<!-- error -->
<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>/paginas/erro/sessaoExpirada.xhtml</location>
</error-page>
<error-page>
<exception-type>java.lang.RuntimeException</exception-type>
<location>/paginas/erro/erro500.xhtml</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/paginas/erro/erro500.xhtml</location>
</error-page>
<error-page>
<error-code>403</error-code>
<location>/paginas/erro/erro403.xhtml</location>
</error-page>
<!-- this definition throws the exception -->
<error-page>
<error-code>404</error-code>
<location>/paginas/erro/erro404.xhtml</location>
</error-page>
我们遇到了同样的问题,现在这是WAS v8.5.5.x 中的一个已知错误
我们打开了IBM的PMR,刚刚收到他们的修复:这是APAR PI26908
我不知道它是否会包含在WAS v8.5.5.4中(我们现在使用WAS V88.5.5.3)
还有这个修复程序,我们需要在web容器上设置com.ibm.ws.webcontainer.deferreServletRequestListenerDestroyOnError=true
您应该联系然后接收此iFix
也许为时已晚,但更多信息:
- APAR:http://www-01.ibm.com/support/docview.wss?uid=swg1PI26908
- "修复":http://www-01.ibm.com/support/knowledgecenter/api/content/nl/hu/SS7K4U_8.5.5/com.ibm.websphere.nd.doc/ae/rweb_custom_props.html#com.ibm.ws.webcontainer.deferServletRequestListenerDestroyOnError
短:应向server.xml
添加一个自定义属性,其中包含以下内容:
<webContainer deferServletRequestListenerDestroyOnError="true" />
属性描述:"如果此自定义属性设置为true,则web容器使CDI能够在自定义错误页面上正常工作"(属性默认为false)