1 Reply Latest reply on Jan 16, 2012 5:23 PM by Jason Porter

    NullPointerException in Seam Securiry

    Assen Todorov Newbie

      Hi,


      I try to implement the use case, where an user try to login, while the session has expired, but
      I get the following NPE from Seam Security:


      11:36:08,310 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/dms].[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception: java.lang.NullPointerException
           at org.jboss.seam.faces.security.SecurityPhaseListener.performObservation(SecurityPhaseListener.java:148) [:3.0.2.Final]
           at org.jboss.seam.faces.security.SecurityPhaseListener.observeRestoreView(SecurityPhaseListener.java:87) [:3.0.2.Final]
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_12]
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_12]
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_12]
           at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_12]
           at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:305) [:6.0.0.Final]
           at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54) [:6.0.0.Final]
           at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163) [:6.0.0.Final]
           at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:299) [:6.0.0.Final]
           at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:188) [:6.0.0.Final]
           at org.jboss.weld.introspector.ForwardingWeldMethod.invokeOnInstance(ForwardingWeldMethod.java:59) [:6.0.0.Final]
           at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:198) [:6.0.0.Final]
           at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:270) [:6.0.0.Final]
           at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:253) [:6.0.0.Final]
           at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:222) [:6.0.0.Final]
           at org.jboss.weld.manager.BeanManagerImpl.notifyObservers(BeanManagerImpl.java:611) [:6.0.0.Final]
           at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:604) [:6.0.0.Final]
           at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:598) [:6.0.0.Final]
           at org.jboss.seam.faces.event.PhaseEventBridge.handlePhase(PhaseEventBridge.java:95) [:3.0.2.Final]
           at org.jboss.seam.faces.event.PhaseEventBridge.afterPhase(PhaseEventBridge.java:99) [:3.0.2.Final]
           at org.jboss.seam.faces.event.DelegatingPhaseListener.afterPhase(DelegatingPhaseListener.java:51) [:3.0.2.Final]
           at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:185) [:2.0.3-]
           at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:103) [:2.0.3-]
           at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:107) [:2.0.3-]
           at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114) [:2.0.3-]
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:308) [:2.0.3-]
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324) [:6.0.0.Final]
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]
           at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79) [:]
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:6.0.0.Final]
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]
           at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67) [:6.0.0.Final]
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:6.0.0.Final]
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:6.0.0.Final]
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]
           at org.jboss.seam.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:65) [:3.0.0.Final]
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:6.0.0.Final]
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]
           at org.jboss.seam.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:72) [:3.0.0.Final]
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:6.0.0.Final]
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [:6.0.0.Final]
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) [:6.0.0.Final]
           at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181) [:6.0.0.Final]
           at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285) [:1.1.0.Final]
           at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261) [:1.1.0.Final]
           at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88) [:6.0.0.Final]
           at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100) [:6.0.0.Final]
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) [:6.0.0.Final]
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [:6.0.0.Final]
           at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) [:6.0.0.Final]
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [:6.0.0.Final]
           at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53) [:6.0.0.Final]
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [:6.0.0.Final]
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [:6.0.0.Final]
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654) [:6.0.0.Final]
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [:6.0.0.Final]
           at java.lang.Thread.run(Thread.java:619) [:1.6.0_12]
      



      The method in Seam Security where the NPE occurs looks like this :


      146    private void performObservation(PhaseEvent event, PhaseIdType phaseIdType) {
      147        UIViewRoot viewRoot = (UIViewRoot) event.getFacesContext().getViewRoot();
      148        List<? extends Annotation> restrictionsForPhase = getRestrictionsForPhase(phaseIdType, viewRoot.getViewId());
      149        if (restrictionsForPhase != null) {
      150            log.debugf("Enforcing on phase %s", phaseIdType);
      151            enforce(event.getFacesContext(), viewRoot, restrictionsForPhase);
      152        }
      153    }
      



      I use Seam 3.0.0.Final on JBoss 6.1.0.


      What can I do to prevent this NPE?
      Any suggestions?