我在访问应用程序的任何视图(xhtml)时遇到问题。 javax.enterprise.context.ContextNotActiveException:如果我设置了error-page标记,则访问任何视图时会发生以下异常。应用程序正常工作,但访问任何视图时发生异常。如果删除error-page标记的配置,则不会发生异常。我使用的是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>
答案 0 :(得分:3)
我们遇到了同样的问题,现在这是WAS v8.5.5.x中已知的错误
我们开了IBM的PMR,刚收到他们的修复:这是APAR PI26908
我不知道它是否会包含在WAS v8.5.5.4中(我们现在使用的是WAS v8.5.5.3)
另外,通过此修复,我们需要在Web容器上设置com.ibm.ws.webcontainer.deferServletRequestListenerDestroyOnError = true
您应该联系然后接收此iFix
答案 1 :(得分:1)
可能为时已晚,但还有更多信息:
简短:应向server.xml
添加包含以下内容的自定义属性:
<webContainer deferServletRequestListenerDestroyOnError="true" />
属性的描述:“如果此自定义属性设置为true,则Web容器使CDI能够在自定义错误页面上正常工作”(属性默认为false)