【发布时间】:2014-04-17 14:04:36
【问题描述】:
我在访问我的应用程序的任何视图 (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>
【问题讨论】:
-
原始消息已编辑。感谢回复
-
看起来错误出在错误页面本身。你在里面引用任何豆子吗?要排除一个和另一个,请尝试使用“空”错误页面,只需打印一些测试文本。至少,去掉所有的 EL 表达式并将它们一一添加,直到错误再次发生(此时您确定了原因)。
-
Balusc,我注意到该错误仅在我为 HTTP 404 代码设置错误页面时发生。即使使用简单的文本(“错误 404”),也会发生错误。对于错误页面 500 和 403,问题不会发生。这个错误页面的定义有正确的顺序吗?我编辑了原始帖子并将我的所有设置都放在了错误页面上。感谢您的帮助 PS:对不起我的“英语不好”
标签: jsf primefaces omnifaces