DynaView and IllegalStateException

Splash Forums PrettyFaces Users DynaView and IllegalStateException

This topic contains 4 replies, has 2 voices, and was last updated by  mkrstich 6 years, 7 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #17878

    mkrstich
    Participant

    Hi,

    My application is built on JSF 2.0 and PrimeFaces 2.2. Tomcat throws

    ServletException with message “FacesContext argument was null.” when clicked on the certain action button/link which is mapped in pretty-config with dynamic view.

    This is fragment from view page (primefaces menu item):

    <p:menuitem value="Manage profile" ajax="false" action="pretty:editProfile"/>

    In pretty-config.xml there is:

    <url-mapping id="editProfile">

    <pattern value="/profile/edit"/>

    <view-id>#{dispatcher.getEditProfileView}</view-id>

    </url-mapping>

    In dispatcher bean I have injected session bean and method that returns view path, something like this:

    public String getEditProfileView() {

    if (getUser().isLoggedIn()) // user is managed property

    return "/faces/editProfile.xhtml";

    else

    return "/faces/index.xhtml";

    }

    faces-config.xml fragment:

    <navigation-rule>

    <from-view-id>*</from-view-id>

    <navigation-case>

    <from-outcome>editProfile</from-outcome>

    <to-view-id>/editProfile.xhtml</to-view-id>

    <redirect/>

    </navigation-case>

    When loaded URL is e.g.

    http://localhost:8084/profile/mycontacts

    and I click the “My profile” menu item (or another one – it is same logic) Tomcat throws the exception. In case of direct navigation (by typing URL in the browser address bar), it works fine.

    This is complete stack trace:

    Feb 25, 2011 11:50:10 AM org.apache.catalina.core.ApplicationDispatcher invoke

    SEVERE: Servlet.service() for servlet Faces Servlet threw exception

    java.lang.IllegalStateException: FacesContext argument was null.

    at com.ocpsoft.pretty.faces.util.Assert.notNull(Assert.java:30)

    at com.ocpsoft.pretty.PrettyContext.getCurrentInstance(PrettyContext.java:119)

    at com.ocpsoft.pretty.PrettyContext.getCurrentInstance(PrettyContext.java:107)

    at com.ocpsoft.pretty.faces.event.PrettyPhaseListener.afterPhase(PrettyPhaseListener.java:86)

    at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:189)

    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:107)

    at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:110)

    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

    at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:115)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

    at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)

    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.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)

    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)

    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)

    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)

    at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:90)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

    at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)

    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:298)

    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)

    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)

    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)

    at java.lang.Thread.run(Thread.java:619)

    Feb 25, 2011 11:50:10 AM org.apache.catalina.core.StandardWrapperValve invoke

    SEVERE: Servlet.service() for servlet default threw exception

    java.lang.IllegalStateException: FacesContext argument was null.

    at com.ocpsoft.pretty.faces.util.Assert.notNull(Assert.java:30)

    at com.ocpsoft.pretty.PrettyContext.getCurrentInstance(PrettyContext.java:119)

    at com.ocpsoft.pretty.PrettyContext.getCurrentInstance(PrettyContext.java:107)

    at com.ocpsoft.pretty.faces.event.PrettyPhaseListener.afterPhase(PrettyPhaseListener.java:86)

    at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:189)

    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:107)

    at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:110)

    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

    at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:115)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

    at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)

    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.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)

    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)

    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)

    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)

    at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:90)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

    at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)

    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:298)

    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)

    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)

    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)

    at java.lang.Thread.run(Thread.java:619)

    Any thoughts will be helpful!

    Thanks

    p.s. sorry for my bad English

    #20741

    Hi mkrstich,

    What distribution of JSF2 are you using? MyFaces? Mojarra? Version?

    Also, which version of PrettyFaces?

    Thanks,

    Lincoln

    #20742

    mkrstich
    Participant

    My configuration is:

    – JSF 2 (Mojarra distribution)

    – Tomcat 6.0.26

    – PrettyFaces version 3.2 (but also tried latest 3.2.1-snapshot).

    – JSP-EL 2.2, JDK 1.6 (if relevant)

    Thanks in advice

    Mladen

    #20743

    Which version of Mojarra?

    Could you also please use a program such as HTTPFox to verify which URL is being submitted when you click the buttons? FacesContext should never be null at the point where your Exception trace says it is failing – this leads me to think that something else is causing FacesContext to be null.

    https://addons.mozilla.org/en-us/firefox/addon/httpfox/

    Either way, I have just patched prettyfaces to attempt to compensate for this new failure:

    Try the latest snapshot in about 15 minutes from my posting this:

    https://github.com/ocpsoft/prettyfaces/wiki/Snapshots

    Thanks,

    Lincoln

    #20744

    mkrstich
    Participant

    Hi,

    I downloaded latest snapshot (prettyfaces-jsf2-3.2.1-20110225.223322-4.jar) and tried again, but with no changes…

    HTTPFox refers to correct URL, it logged only one request (HTTP POST) that results with error. That’s all.

    Mojarra version is 2.0.2.FCS.

    In my app, I have some kind of user menu which is visible while user is logged in. Weirdest thing is that my navigation works fine when I reproduce requests (requests to dyna view pages) from prettyfaces static view paths. Actually, I tried to use dynamic views for authorization control.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

Comments are closed.