PrettyFaces causes Solder exception handler to be ignored

Splash Forums PrettyFaces Users PrettyFaces causes Solder exception handler to be ignored

This topic contains 3 replies, has 3 voices, and was last updated by  Christian Kaltepoth 3 years, 3 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #23594

    pdhaigh
    Participant

    Hi,

    I have implemented an exception handler to deal with the WELD-000321 No conversation found to restore… issue. This worked nicely until I added PrettyFaces (which otherwise is providing friendly URL perfectly!).

    Now, on any request that has an invalid CID, that is being rewritten by PrettyFaces, the exception is thrown and not caught by the handler.

    What I would like to know is; is it possible to have PrettyFaces filter requests, but when an error occurs it be handled by Solder handlers as usual?

    PrettyFaces 3.3.3, Solder 3.1.1, JBoss AS 7.1.3, Weld 1.1.9

     

    Here is the handler:

    `
    public void onNonexistentConversation(@Handles CaughtException evt, HttpServletRequest request, HttpServletResponse response)
    {
    evt.handled();
    handleNonExistentConversation(evt.getException(), request, response);
    }

    public void onNonexistentConversationWeld(@Handles CaughtException evt, HttpServletRequest request, HttpServletResponse response)
    {
    log.debug(“Nonexistent Conversation Exception caught”);
    evt.handled();
    handleNonExistentConversation(evt.getException(), request, response);
    }

    private void handleNonExistentConversation(Throwable exception, HttpServletRequest request, HttpServletResponse response)
    {
    log.debug(“Nonexistent Conversation Exception caught”);
    log.trace(“Stack trace:”, exception);
    // We actually want to just redirect to the original page with a fresh conversation.
    String requestUrl = request.getRequestURI()+ (request.getQueryString()!=null ? “?”+request.getQueryString() : “”);
    // Strip any cid params
    requestUrl = requestUrl.replaceAll(“cid=[0-9]*”, “”).replace(“&&”,”&”).replace(“?&”,”?”);
    httpRedirect(requestUrl, response);
    }`
     

    PrettyConfig:

    <url-mapping id="specialist-profile-patient"><br/>
    		<pattern value="/patient/specialist/#{id}/.*" /><br/>
    		<view-id value="/patient/secure/specialist.html" /><br/>
    	</url-mapping>

    When I access the URL:

    http://site.com/patient/specialist/4/Aname?cid=55

    then I see the following in the logs, and a server 500 screen is shown:

    12:36:07,781 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[www.site.com].[/].[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception: org.jboss.weld.con text.NonexistentConversationException: WELD-000321 No conversation found to restore for id 55 at org.jboss.weld.context.AbstractConversationContext.activate(AbstractConversationContext.java:221) [weld-core-1.1.9.Final.jar:2012-08-06 19:12] at org.jboss.weld.jsf.WeldPhaseListener.activateConversations(WeldPhaseListener.java:108) [weld-core-1.1.9.Final.jar:2012-08-06 19:12] at org.jboss.weld.jsf.WeldPhaseListener.beforePhase(WeldPhaseListener.java:85) [weld-core-1.1.9.Final.jar:2012-08-06 19:12] at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:228) [jsf-impl-2.1.11-jbossorg-3.jar:] at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:99) [jsf-impl-2.1.11-jbossorg-3.jar:] at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116) [jsf-impl-2.1.11-jbossorg-3.jar:] at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.11-jbossorg-3.jar:] at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.0.4.Final.jar:2.0.4.Final] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.17.Final.jar:] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.17.Final.jar:] at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:145) [prettyfaces-jsf2-3.3.3.jar:] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.17.Final.jar:] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.17.Final.jar:] at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:840) [jbossweb-7.0.17.Final.jar:] at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:622) [jbossweb-7.0.17.Final.jar:] at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:560) [jbossweb-7.0.17.Final.jar:] at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:488) [jbossweb-7.0.17.Final.jar:] at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:137) [prettyfaces-jsf2-3.3.3.jar:] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.17.Final.jar:] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.17.Final.jar:] at com.site.www.filter.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:24) [classes:] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.17.Final.jar:] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.17.Final.jar:] at com.site.www.security.AutomatedLoginSecurityFilter.doFilter(AutomatedLoginSecurityFilter.java:103) [classes:] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.17.Final.jar:] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.17.Final.jar:] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.17.Final.jar:] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.17.Final.jar:] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:397) [jbossweb-7.0.17.Final.jar:] at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.3.Final.jar:7.1.3.Final] at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:165) [jboss-as-web-7.1.3.Final.jar:7.1.3.Final] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.17.Final.jar:] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.17.Final.jar:] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.17.Final.jar:] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:372) [jbossweb-7.0.17.Final.jar:] at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:505) [jbossweb-7.0.17.Final.jar:] at org.apache.coyote.ajp.AjpProtocol$AjpConnectionHandler.process(AjpProtocol.java:453) [jbossweb-7.0.17.Final.jar:] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:931) [jbossweb-7.0.17.Final.jar:] at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_03]

    If I remove the PrettyFaces config for that page (or any page), and access an invalid converstation ID, my handler does run, and the user is just redirected to the requested page without the cid.

     

     

     

    #23595

    Hi, I’m on a plane right now, but I think your problem is that the solder filter may not be accepting “forward” dispatches. Try setting this in web.xml and playing with the order of filters if that does not work.

    -Lincoln

    #23596

    pdhaigh
    Participant

    Hi Lincoln,

    Thanks very much – the ordering was the key:

    <absolute-ordering>
            <others/>
            <name>com_ocpsoft_prettyfaces</name>
        </absolute-ordering>

    Then everything plays nicely.

    Is there any reason why configuring PrettyFaces to be explictly ordered last like this would cause any other problems?

    Thanks again, much appreciated – I’m glad your flight provides data access! 🙂

    #23604

    I think the only difference with this ordering is that other filters may see the pretty URL instead of the real URL. But I don’t think that there are many cases where this could lead to problems.

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

You must be logged in to reply to this topic.

Comments are closed.