5 Replies Latest reply on May 24, 2006 5:58 PM by Peter Brewer

    Migration problem from CR2 to CR3

    Peter Brewer Novice

      I'm currently trying to upgrade from Seam CR2 to CR3 and have now hit a stumper.

      I have a JSF PhaseListener that requires a user to login before being redirected back to their original page request (which was working fine under CR2). However, the code below now complains about "No active conversation context" when a user first hits a page that requires them to login.

      Any help or ideas on how to solve this would be gratefully received.

      public class LoggedInPhaseListener implements PhaseListener {
      
       private static final Logger log = Logger.getLogger( LoggedInPhaseListener.class );
      
       public void afterPhase ( PhaseEvent event ) {
      
       FacesContext facesContext = FacesContext.getCurrentInstance();
       String viewId = facesContext.getViewRoot().getViewId();
       log.debug( "afterPhase view id: " + viewId );
      
       if ( Contexts.isSessionContextActive() ) {
      
       Context sessionContext = Contexts.getSessionContext();
      
       SecurePages securePages = SecurePages.instance();
       if ( securePages.isSecure( viewId ) ) {
      
       // This is a secure page so check the settings
       User user = null;
       user = ( User ) sessionContext.get( "loggedInUser" );
       SecurePage securePage = securePages.getSecurePage( viewId );
      
       if ( user == null || !securePage.isRoleValid( user.getUserRole() ) ) {
      
       // User is not logged in or does not have privileges for this page
       log.debug( "Redirecting to the login outcome " + securePage.getLoginOutcome() );
      
       // Set the secure page so it can be checked when login completes
       if ( ( securePage.isLoginPage() && sessionContext.get( "destinationPage" ) == null ) || !securePage.isLoginPage() ) {
       log.debug( "Setting destination page to " + securePage );
       sessionContext.remove( "destinationPage" );
       sessionContext.set( "destinationPage", securePage );
       }
      
       // Redirect to the login outcome specified in secure-page.xml
       if ( !securePage.isLoginPage() ) {
       facesContext.getApplication().getNavigationHandler()
       .handleNavigation( facesContext, null, securePage.getLoginOutcome() );
      
       }
      
       }
       } else {
       sessionContext.remove( "destinationPage" );
       log.debug( "Page " + viewId + " does not require authentication." );
       }
      
       } else {
       log.debug( "No Active session context - This should not happen - Error ?" );
       }
      
       }
      
       public void beforePhase ( PhaseEvent event ) {
       // Auto-generated method stub
       }
      
       public PhaseId getPhaseId () {
       // Auto-generated method stub
       return PhaseId.RESTORE_VIEW;
       }
      
      }
      
      


      Produces this stack trace:

      24-05 17:55:00 ERROR [PhaseListenerManager] Exception in PhaseListener RESTORE_VIEW(1) afterPhase
      java.lang.IllegalStateException: No active conversation context
       at org.jboss.seam.core.Pageflow.instance(Pageflow.java:57)
       at org.jboss.seam.jsf.SeamNavigationHandler.handleNavigation(SeamNavigationHandler.java:29)
       at uk.co.iblocks.jsf.LoggedInPhaseListener.afterPhase(LoggedInPhaseListener.java:71)
       at org.apache.myfaces.lifecycle.PhaseListenerManager.informPhaseListenersAfter(PhaseListenerManager.java:89)
       at org.apache.myfaces.lifecycle.LifecycleImpl.restoreView(LifecycleImpl.java:181)
       at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:66)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:137)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:23)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:45)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
       at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
       at java.lang.Thread.run(Thread.java:595)