2012-03-20 33 views
4

所有,會議空指針在RichFaces的

,我發現了以下問題,而試圖訪問會話圖:當我登錄

FacesContext.getCurrentInstance().getExternalContext() 
     .getSessionMap().put("userSession", session); 

我看到這個錯誤,然後我等待幾分鐘,我點擊任何訪問該bean的按鈕。這是在超時之前(我已經設定了60分鐘)。有人可以幫忙嗎?這是一個主要的顯示塞我...

java.lang.NullPointerException 
     at com.sun.faces.context.SessionMap.put(ExternalContextImpl.java:970) 
     at com.mounza.common.Util.logUser(Util.java:129) 
     at com.mounza.common.Util.userStart(Util.java:159) 
     at com.mounza.homepage.UserHomepageAction.<init>(UserHomepageAction.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) 
     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:230) 
     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:69) 
     at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186) 
     at com.sun.faces.application.ValueBindingValueExpressionAdapter.getValue(ValueBindingValueExpressionAdapter.java:113) 
     at org.ajax4jsf.taglib.html.facelets.KeepAliveHandler.apply(KeepAliveHandler.java:76) 
     at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47) 
     at com.sun.facelets.tag.jsf.ComponentHandler.applyNextHandler(ComponentHandler.java:314) 
     at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:169) 
     at com.sun.facelets.tag.jsf.core.ViewHandler.apply(ViewHandler.java:109) 
     at com.sun.facelets.tag.ui.DefineHandler.applyDefinition(DefineHandler.java:64) 
     at com.sun.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:131) 
     at com.sun.facelets.impl.DefaultFaceletContext$TemplateManager.apply(DefaultFaceletContext.java:337) 
     at com.sun.facelets.impl.DefaultFaceletContext.includeDefinition(DefaultFaceletContext.java:307) 
     at com.sun.facelets.tag.ui.InsertHandler.apply(InsertHandler.java:68) 
     at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47) 
     at com.sun.facelets.tag.jsf.core.ViewHandler.apply(ViewHandler.java:109) 
     at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47) 
     at com.sun.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:119) 
     at com.sun.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:49) 
     at com.sun.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:25) 
     at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:248) 
     at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:294) 
     at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:273) 
     at com.sun.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:140) 
     at com.sun.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:113) 
     at com.sun.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:49) 
     at com.sun.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:25) 
     at com.sun.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:95) 
     at com.sun.facelets.FaceletViewHandler.buildView(FaceletViewHandler.java:524) 
     at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:567) 
     at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100) 
     at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176) 
     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 javax.faces.webapp.FacesServlet.service(FacesServlet.java:266) 
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
     at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:349) 
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
     at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206) 
     at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290) 
     at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388) 
     at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515) 
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
     at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:369) 
     at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109) 
     at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83) 
     at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) 
     at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97) 
     at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) 
     at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100) 
     at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) 
     at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78) 
     at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) 
     at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54) 
     at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) 
     at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35) 
     at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) 
     at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:187) 
     at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) 
     at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105) 
     at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) 
     at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79) 
     at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) 
     at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:168) 
     at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237) 
     at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167) 
     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:233) 
     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) 
     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) 
     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 
     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 
     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) 
     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) 
     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602) 
     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) 
     at java.lang.Thread.run(Thread.java:680) 

[編輯] 我有一種感覺,這可能與使用Spring Web安全的日誌記錄在/註銷的事情。使用彈簧時,其他人看到過這樣的東西嗎?

[編輯2] 我重建從頭開始,我得到一個新的錯誤項目,但同樣的問題櫃面有人知道:

SEVERE: java.lang.NullPointerException 
javax.faces.el.EvaluationException: java.lang.NullPointerException 
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102) 
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102) 
    at javax.faces.component.UICommand.broadcast(UICommand.java:387) 
    at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:329) 
    at org.ajax4jsf.component.AjaxViewRoot.broadcastEventsForPhase(AjaxViewRoot.java:304) 
    at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:261) 
    at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:474) 
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82) 
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100) 
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) 
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
    at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:349) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
    at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206) 
    at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290) 
    at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388) 
    at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:369) 
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109) 
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) 
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) 
    at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) 
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) 
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) 
    at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) 
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:187) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) 
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) 
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79) 
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) 
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:168) 
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237) 
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167) 
    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:233) 
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) 
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) 
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) 
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) 
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602) 
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) 
    at java.lang.Thread.run(Thread.java:680) 
Caused by: java.lang.NullPointerException 
    at org.apache.catalina.connector.Request.parseParameters(Request.java:2599) 
    at org.apache.catalina.connector.Request.getParameter(Request.java:1106) 
    at org.apache.catalina.connector.RequestFacade.getParameter(RequestFacade.java:355) 
    at javax.servlet.ServletRequestWrapper.getParameter(ServletRequestWrapper.java:158) 
    at javax.servlet.ServletRequestWrapper.getParameter(ServletRequestWrapper.java:158) 
    at com.sun.faces.context.RequestParameterMap.get(ExternalContextImpl.java:1152) 
    at com.sun.faces.context.RequestParameterMap.get(ExternalContextImpl.java:1140) 
    at java.util.Collections$UnmodifiableMap.get(Collections.java:1282) 
    at com.mounza.homepage.UserHomepageAction.update(UserHomepageAction.java:47) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at org.apache.el.parser.AstValue.invoke(AstValue.java:191) 
    at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276) 
    at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68) 
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88) 
    ... 56 more 
+2

究竟哪個Mojarra版本?我搜索了所有2.0.x源代碼,但找不到與您的堆棧跟蹤中的行號相匹配的版本。至少,在其他版本中,它暗示會話屬性名稱只是'空'。所以這會把問題帶回調用者,你的'logUser()'方法。它將'null'設置爲會話屬性名稱。 – BalusC 2012-03-20 14:29:24

+0

@BalusC我正在使用2.0.3 ...但我對上述帖子進行了一些更改。 – KVISH 2012-03-21 01:05:41

回答

7

這裏的根本原因的相關部分:

Caused by: java.lang.NullPointerException 
    at org.apache.catalina.connector.Request.parseParameters(Request.java:2599) 
    at org.apache.catalina.connector.Request.getParameter(Request.java:1106) 
    at org.apache.catalina.connector.RequestFacade.getParameter(RequestFacade.java:355) 
    at javax.servlet.ServletRequestWrapper.getParameter(ServletRequestWrapper.java:158) 
    at javax.servlet.ServletRequestWrapper.getParameter(ServletRequestWrapper.java:158) 
    at com.sun.faces.context.RequestParameterMap.get(ExternalContextImpl.java:1152) 
    at com.sun.faces.context.RequestParameterMap.get(ExternalContextImpl.java:1140) 
    at java.util.Collections$UnmodifiableMap.get(Collections.java:1282) 
    at com.mounza.homepage.UserHomepageAction.update(UserHomepageAction.java:47) 
    ... 

此異常表示HTTP請求已過期/回收。我沒有看到代碼中的任何東西,但是這個異常反過來表明您正在獲取FacesContextExternalContext的實例,或者ExternalContext#getRequestParameterMap()返回的映射作爲託管bean的類變量,它位於更廣的範圍不是像這樣的請求範圍:

@ManagedBean 
@ViewScoped // Or @SessionScoped or @ApplicationScoped 
public class UserHomepageAction { 

    private Map<String, String> params; 

    public UserHomepageAction() { 
     params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap(); 
    } 

    public void update() { 
     String value = params.get(name); // Fail!! 
     // ... 
    } 

} 

你應該從未做到這一點。 bean的生命週期跨越多個HTTP請求。在bean的構建過程中,在不同的HTTP請求期間調用bean的操作方法。而應該獲得線程/請求局部變量的方法的局部範圍:

public void update() { 
     Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap(); 
     String value = params.get(name); // OK!! 
     // ... 
    } 

無關到具體的問題:與請求參數映射像擺弄是一種氣味。你看過<f:viewParam>?另見What can <f:metadata>, <f:viewParam> and <f:viewAction> be used for?

+0

你100%正確,那是我的代碼中的錯誤。謝謝您的幫助!! – KVISH 2012-03-21 05:15:29

+1

不客氣。 – BalusC 2012-03-21 05:17:02