1 2 Previous Next 16 Replies Latest reply on May 4, 2012 2:31 PM by rshan

    ViewScope redirect after login error - IllegalStateException

    langerc

      I have implemented ViewScope for authorization of some areas of my page. After searching for 1 Day i found out that the current Beta3 is not working for me. I have tried all of the samples and startet pulling my hairs out because none of the Restrictions applied, and the @Secures implementation was nat called.


      UrlMapping an url to a page was working (see the viewconfig below), The Security constraints did not apply for once. I tried my own Secures, NotLoggedIn and all of the samples i found.


      With 3.1.0-SNAPSHOT it seems to work better. If i try to access a page that is beeing protected by a ViewConfig i get a redirection to the login page. This is the behavior i am looking for.


      After login the redirect back to the page throws an exception. The page accessed has no queryparams its a normal url /admin/index.xhtml



      "INFO  (javax.enterprise.resource.webcontainer.jsf.context) (http--127.0.0.1-8080-2) Exception when handling error trying to reset the response.: java.lang.IllegalStateException
           at org.apache.catalina.connector.ResponseFacade.sendRedirect(ResponseFacade.java:436) (jbossweb-7.0.1.Final.jar:7.0.2.Final)
           at javax.servlet.http.HttpServletResponseWrapper.sendRedirect(HttpServletResponseWrapper.java:170) (jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final)
           at javax.servlet.http.HttpServletResponseWrapper.sendRedirect(HttpServletResponseWrapper.java:170) (jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final)
           at org.jboss.weld.servlet.ConversationPropagationFilter$1.sendRedirect(ConversationPropagationFilter.java:90) (weld-core-1.1.2.Final.jar:2011-07-26 15:02)
           at com.sun.faces.context.ExternalContextImpl.redirect(ExternalContextImpl.java:576) (jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT)
           at javax.faces.context.ExternalContextWrapper.redirect(ExternalContextWrapper.java:462) (jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1)
           at org.jboss.seam.faces.environment.SeamExternalContext.redirect(SeamExternalContext.java:71) (seam-faces-3.1.0-SNAPSHOT.jar:)
           at org.jboss.seam.faces.environment.SeamExternalContext$Proxy$_$$_WeldClientProxy.redirect(SeamExternalContext$Proxy$_$$_WeldClientProxy.java) (seam-faces-3.1.0-SNAPSHOT.jar:)
           at com.sun.faces.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:182) (jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT)
           at com.ocpsoft.pretty.faces.application.PrettyNavigationHandler.handleNavigation(PrettyNavigationHandler.java:64) (prettyfaces-jsf2-3.3.0.jar:)
           at org.jboss.seam.faces.event.SeamPreNavigationHandler.handleNavigation(SeamPreNavigationHandler.java:63) (seam-faces-3.1.0-SNAPSHOT.jar:)
           at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:130) (jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT)"





      this is my ViewConfig



      @ViewConfig
      public interface MyAppViewConfig {
        
          static enum MyPages {
        
              @FacesRedirect
              @ViewPattern("/admin/*")
              @Private
              @LoginView("/login.xhtml")
              @AccessDeniedView("/denied.xhtml")        
              PRIVATE,
      
              @UrlMapping(pattern="/test/")
              @ViewPattern("/admin/index.xhtml")
              TEST,
              
              @ViewPattern("/login.xhtml")
              LOGIN;
          }  
      
      }



      Summary:




      1. unauthenticated i try to access /admin/index.xhtml

      2. the @Secures function is called returning false because not authenticated

      3. i get redirected to the login page which is what i expected

      4. i authenticate with a valid user

      5. the exception is thrown instead of redirecting back to the page.





      Thank you guys for the excellent work!


      Maybe this feature would be a nice addon to the migration guide. CaptureCurrentView from Seam2 did a simmilar thing.



        1 2 Previous Next