我在JBoss 5.1.0上运行的第一个JSF / IceFaces(版本1.8.2)应用程序出了问题。
我在一段时间后收到一个例外,告诉我会话问题。这很奇怪,因为我根本不在代码中使用会话。以下日志显示,由于此错误(来自JBoss),我的后备bean都无法实例化:
com.sun.faces.mgbean.ManagedBeanCreationException: Cant instantiate class: bean.Abgrenzungsreise. at com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:191) at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:106) at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:368) at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:222) at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:86) at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54) at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72) at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:61) at org.apache.el.parser.AstValue.getValue(AstValue.java:107) at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186) at javax.faces.component.UISelectItems.getValue(UISelectItems.java:141) at com.icesoft.faces.renderkit.dom_html_basic.MenuRenderer.getSelectItems(MenuRenderer.java:637) at com.icesoft.faces.renderkit.dom_html_basic.MenuRenderer.countSelectOptionsRecursive(MenuRenderer.java:448) at com.icesoft.faces.renderkit.dom_html_basic.MenuRenderer.renderSelect(MenuRenderer.java:377) at com.icesoft.faces.renderkit.dom_html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:119) at com.icesoft.faces.component.ext.renderkit.MenuRenderer.encodeEnd(MenuRenderer.java:51) at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:861) at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:370) at com.icesoft.faces.renderkit.dom_html_basic.GridRenderer.encodeChildren(GridRenderer.java:208) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837) at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:358) at com.icesoft.faces.renderkit.dom_html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:96) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837) at com.icesoft.faces.component.util.CustomComponentUtils.renderChild(CustomComponentUtils.java:339) at com.icesoft.faces.component.paneltabset.PanelTabSetRenderer.writeTabCell(PanelTabSetRenderer.java:977) at com.icesoft.faces.component.paneltabset.PanelTabSetRenderer.encodeEnd(PanelTabSetRenderer.java:423) at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:861) at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:503) at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:497) at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:497) at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:497) at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:497) at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:456) at com.icesoft.faces.application.D2DViewHandler.renderView(D2DViewHandler.java:159) at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100) at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) at com.icesoft.faces.webapp.http.core.JsfLifecycleExecutor.apply(JsfLifecycleExecutor.java:19) at com.icesoft.faces.context.View$2$1.respond(View.java:48) at com.icesoft.faces.webapp.http.servlet.ServletRequestResponse.respondWith(ServletRequestResponse.java:201) at com.icesoft.faces.context.View$2.serve(View.java:77) at com.icesoft.faces.context.View.servePage(View.java:149) at com.icesoft.faces.webapp.http.core.SingleViewServer.service(SingleViewServer.java:52) at com.icesoft.faces.webapp.http.common.ServerProxy.service(ServerProxy.java:11) at com.icesoft.faces.webapp.http.servlet.MainSessionBoundServlet$4.service(MainSessionBoundServlet.java:149) at com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer.service(PathDispatcherServer.java:24) at com.icesoft.faces.webapp.http.servlet.BasicAdaptingServlet.service(BasicAdaptingServlet.java:16) at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:23) at com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:53) at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:23) at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:131) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:638) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:444) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:382) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:310) at org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:696) at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:667) at org.apache.jsp.index_jsp._jspService(index_jsp.java:58) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190) at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92) at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126) at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:662) Caused by: com.icesoft.faces.webapp.http.core.SessionExpiredException: User session has expired or it was invalidated. at com.icesoft.faces.webapp.http.servlet.ProxyHttpSession.getAttribute(ProxyHttpSession.java:77) at com.icesoft.faces.webapp.http.servlet.ServletSessionAttributeMap.getAttribute(ServletSessionAttributeMap.java:16) at com.icesoft.faces.context.AbstractAttributeMap.containsKey(AbstractAttributeMap.java:85) at com.sun.faces.mgbean.BeanManager.isBeanInScope(BeanManager.java:177) at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:82) at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54) at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72) at bean.Abgrenzungsreise.(Abgrenzungsreise.java:39) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at java.lang.Class.newInstance0(Class.java:355) at java.lang.Class.newInstance(Class.java:308) at com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:186) ... 86 more
Caused by: java.lang.IllegalStateException: getAttribute: Session already invalidated at org.apache.catalina.session.StandardSession.getAttribute(StandardSession.java:1032) at org.apache.catalina.session.StandardSessionFacade.getAttribute(StandardSessionFacade.java:110) at com.icesoft.faces.webapp.http.servlet.ProxyHttpSession.getAttribute(ProxyHttpSession.java:75) ... 100 more 2011-01-28 08:05:54,326 ERROR [com.icesoft.faces.context.View] (http-0.0.0.0-8080-3) Problem encountered during View.servePage com.sun.faces.mgbean.ManagedBeanCreationException: Cant instantiate class: bean.Abgrenzungsreise. at com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:191) at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:106) at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:368) at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:222) at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:86) at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54) at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72) at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:61) at org.apache.el.parser.AstValue.getValue(AstValue.java:107) at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186) at javax.faces.component.UISelectItems.getValue(UISelectItems.java:141) at com.icesoft.faces.renderkit.dom_html_basic.MenuRenderer.getSelectItems(MenuRenderer.java:637) at com.icesoft.faces.renderkit.dom_html_basic.MenuRenderer.countSelectOptionsRecursive(MenuRenderer.java:448) at com.icesoft.faces.renderkit.dom_html_basic.MenuRenderer.renderSelect(MenuRenderer.java:377) at com.icesoft.faces.renderkit.dom_html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:119) at com.icesoft.faces.component.ext.renderkit.MenuRenderer.encodeEnd(MenuRenderer.java:51) at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:861) at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:370) at com.icesoft.faces.renderkit.dom_html_basic.GridRenderer.encodeChildren(GridRenderer.java:208) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837) at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:358) at com.icesoft.faces.renderkit.dom_html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:96) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837) at com.icesoft.faces.component.util.CustomComponentUtils.renderChild(CustomComponentUtils.java:339) at com.icesoft.faces.component.paneltabset.PanelTabSetRenderer.writeTabCell(PanelTabSetRenderer.java:977) at com.icesoft.faces.component.paneltabset.PanelTabSetRenderer.encodeEnd(PanelTabSetRenderer.java:423) at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:861) at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:503) at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:497) at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:497) at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:497) at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:497) at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:456) at com.icesoft.faces.application.D2DViewHandler.renderView(D2DViewHandler.java:159) at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100) at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) at com.icesoft.faces.webapp.http.core.JsfLifecycleExecutor.apply(JsfLifecycleExecutor.java:19) at com.icesoft.faces.context.View$2$1.respond(View.java:48) at com.icesoft.faces.webapp.http.servlet.ServletRequestResponse.respondWith(ServletRequestResponse.java:201) at com.icesoft.faces.context.View$2.serve(View.java:77) at com.icesoft.faces.context.View.servePage(View.java:149) at com.icesoft.faces.webapp.http.core.SingleViewServer.service(SingleViewServer.java:52) at com.icesoft.faces.webapp.http.common.ServerProxy.service(ServerProxy.java:11) at com.icesoft.faces.webapp.http.servlet.MainSessionBoundServlet$4.service(MainSessionBoundServlet.java:149) at com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer.service(PathDispatcherServer.java:24) at com.icesoft.faces.webapp.http.servlet.BasicAdaptingServlet.service(BasicAdaptingServlet.java:16) at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:23) at com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:53) at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:23) at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:131) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:638) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:444) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:382) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:310) at org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:696) at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:667) at org.apache.jsp.index_jsp._jspService(index_jsp.java:58) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190) at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92) at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126) at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:662) Caused by: com.icesoft.faces.webapp.http.core.SessionExpiredException: User session has expired or it was invalidated. at com.icesoft.faces.webapp.http.servlet.ProxyHttpSession.getAttribute(ProxyHttpSession.java:77) at com.icesoft.faces.webapp.http.servlet.ServletSessionAttributeMap.getAttribute(ServletSessionAttributeMap.java:16) at com.icesoft.faces.context.AbstractAttributeMap.containsKey(AbstractAttributeMap.java:85) at com.sun.faces.mgbean.BeanManager.isBeanInScope(BeanManager.java:177) at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:82) at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54) at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72) at bean.Abgrenzungsreise.(Abgrenzungsreise.java:39) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at java.lang.Class.newInstance0(Class.java:355) at java.lang.Class.newInstance(Class.java:308) at com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:186) ... 86 more Caused by: java.lang.IllegalStateException: getAttribute: Session already invalidated at org.apache.catalina.session.StandardSession.getAttribute(StandardSession.java:1032) at org.apache.catalina.session.StandardSessionFacade.getAttribute(StandardSessionFacade.java:110) at com.icesoft.faces.webapp.http.servlet.ProxyHttpSession.getAttribute(ProxyHttpSession.java:75) ... 100 more
我发现在最后一次用户活动后半小时就抛出了异常。
答案 0 :(得分:2)
IceFaces论坛报道了同样的问题:
建议的解决方案是:
一旦我们将异步模式设置为
,就会发生这种情况<!-- Specifies to the ICEfaces framework that synchronous update mode is to be used. By default, ICEfaces uses asynchronous update mode to support server-initiated updates (AJAX push). Setting to true will enable synchronous update mode and disable AJAX push features. --> <context-param> <param-name>com.icesoft.faces.synchronousUpdate</param-name> <param-value>true</param-value> </context-param>
当这是假的时候,我们得到了很好的小会话超时消息。 当这是真的时,会话超时行为是堆栈跟踪。
和
与此同时,我已经从ICEfaces 1.8.2切换到svn存储库中的内容(1.8.3+)。而且行为也发生了变化。没有崩溃了。
关于你没有在任何地方使用会话的声明,stacktrace告诉它在抛出此异常时尝试创建会话范围的托管bean。所以你肯定在使用会话:)
更新:您确实不应将(基于请求!!)FacesContext
分配为static
变量。此外,需要在<managed-property>
中faces-config.xml
注入其他bean。否则它根本不是“注入”,而只是手动访问另一个bean。通过注入,您可以让JSF将其他bean设置为当前bean的属性。可以找到一个示例here。
答案 1 :(得分:1)
异常的原因在于我的SessionBean类 我上面问过原因是否可以通过facesContext将bean注入另一个bean。 现在我给出自己的答案:“是的,这可能是原因。”
public class MySessionBean {
private static FacesContext facesContext = FacesContext.getCurrentInstance();
private utils.AnotherSessionBean injectedSessionBean = (utils.AnotherSessionBean) facesContext.getApplication().getELResolver().getValue(facesContext.getELContext(), null, "anotherSessionBean");
// ...
}
我可以自由地在任何方法或构造函数之外实例化当前的FacesContext,这不是一个好主意,因为在会话超时后我使用了旧的或不使用会话上下文。 MySessionBean已重新加载或获取它的新实例,但它没有刷新FacesContext。其结果如上所述^^
结论:因此,让FacesContext属于方法或构造函数的代码块。
非常感谢你的帮助!