Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6806891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:45:56+00:00 2026-05-26T19:45:56+00:00

I am using a phase listener to manage things like logon and conversation scope.

  • 0

I am using a phase listener to manage things like logon and conversation scope. In some situations I want to redirect. The most obvious is when the user is not logged on and they are attempting to access a protected page.

Currently my PhaseListener runs After Restore View. This is sometimes too late. When the user logs off the page is disposed and they are redirected back to the logon page. That page disposal causes some AJAX events in IceFaces – only I’ve destroyed the session so beans are missing state. This causes exceptions during Restore View, which appears to access the backing bean through EL in the page.

If I move my phase listener to Before Restore View and attempt to redirect using the ExternalContext I end up with a NullPointerException.

java.lang.NullPointerException
com.sun.faces.lifecycle.RestoreViewPhase.notifyAfter(RestoreViewPhase.java:301)
com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:114)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67)
com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:118)

One option I could use would be use use a Servlet Filter for this work. It would also cover non-JSF requests. I don’t know how much of JSF will be available (and how much I actually need) in this case and it is not immediately clear how I cam make my filter happen after things like the ConversationPropagationFilter and before PrettyFilter.

Thanks
– Richard

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:45:57+00:00Added an answer on May 26, 2026 at 7:45 pm
    java.lang.NullPointerException
      com.sun.faces.lifecycle.RestoreViewPhase.notifyAfter(RestoreViewPhase.java:301)
    

    That’s an old bug which is already been fixed in Mojarra 2.1 . The source of RestoreViewPhase#notifyAfter() method of for example Mojarra 2.0.2 says the following:

    299  private void notifyAfter(FacesContext context, Lifecycle lifecycle) {
    300      UIViewRoot viewRoot = context.getViewRoot();
    301      MethodExpression afterPhase = viewRoot.getAfterPhaseListener();
    

    which means that viewRoot is null. That can happen if FacesContext#responseComplete() is been called before that point, which in turn is implicitly done by ExternalContext#rediect(). After Mojarra 2.1, a nullcheck on viewRoot is been added which fixes this bug.

    So, upgrade to at least Mojarra 2.1. It’s currently already at 2.1.4.


    As to your (unrelated) note:

    One option I could use would be use use a Servlet Filter for this work. It would also cover non-JSF requests. I don’t know how much of JSF will be available (and how much I actually need) in this case and it is not immediately clear how I cam make my filter happen after things like the ConversationPropagationFilter and before PrettyFilter.

    JSF stores managed beans and a lot of other information as attributes of HttpSession and ServletContext, all which are available in the Filter. So that should be doable. As to the filter invocation order; that’s just controllable by the <filter-mapping> order in web.xml.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to add some files to the Compile Sources build phase using
I'm using NSOperationQueue to manage a phase of an iOS application which is quite
I have been using a Phase Listener to debug my JSF application. Now I'm
Using ASP.NET MVC there are situations (such as form submission) that may require a
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
I'm using scriptaculous Builder to generate some DOM elements dynamically, and one of them
We are in the beginning coding phase for project that we are using JPA
I am making a web application using JBoss Seam 2.2.0, and I want to
Im using http://phase-change.org/jquery.gridlayout to achieve the fluid layout of several divs in my layout.
I'm using the LUA middleclass library now after some problems and I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.