Requesting a URL which is not mapped by Prettyfaces

Splash Forums PrettyFaces Users Requesting a URL which is not mapped by Prettyfaces

This topic contains 3 replies, has 2 voices, and was last updated by  Christian Kaltepoth 6 years, 1 month ago.

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

    RedShadow
    Participant

    I don’t know if i missconfigured something but it’s really strange that i get about 10000 lines of stacktrace when I request something like:

    http://localhost/admin/RES_NOT_FOUND which is not mapped.

    Environment:

    Glassfish 3.1.1(Mojarra 2.1.1)

    PrettyFaces 3.3.0

    Windows

    pretty-config.xml:

    <rewrite match=”^((?!.*.w*).)*$” trailingSlash=”append” toCase=”lowercase”/>

    <rewrite match=”^/admin/login.xhtml$” substitute=”/admin/” inbound=”false”/>

    <rewrite match=”^/admin/admin.xhtml$” substitute=”/admin/” inbound=”false”/>

    Filtermapping-order:

    <filter-mapping>

    <filter-name>HttpsFilter</filter-name>

    <url-pattern>/admin/*</url-pattern>

    <dispatcher>FORWARD</dispatcher>

    <dispatcher>REQUEST</dispatcher>

    <dispatcher>ERROR</dispatcher>

    <dispatcher>ASYNC</dispatcher>

    </filter-mapping>

    <filter-mapping>

    <filter-name>FileUpload Filter</filter-name>

    <url-pattern>/*</url-pattern>

    <dispatcher>FORWARD</dispatcher>

    <dispatcher>REQUEST</dispatcher>

    <dispatcher>ASYNC</dispatcher>

    </filter-mapping>

    <filter-mapping>

    <filter-name>HibernateSessionFilter</filter-name>

    <url-pattern>/*</url-pattern>

    <dispatcher>FORWARD</dispatcher>

    <dispatcher>REQUEST</dispatcher>

    <dispatcher>ERROR</dispatcher>

    <dispatcher>ASYNC</dispatcher>

    </filter-mapping>

    <filter-mapping>

    <filter-name>LoginRedirectFilter</filter-name>

    <url-pattern>/admin/*</url-pattern>

    </filter-mapping>

    <filter-mapping>

    <filter-name>HideServerInfoFilter</filter-name>

    <url-pattern>/*</url-pattern>

    <dispatcher>FORWARD</dispatcher>

    <dispatcher>REQUEST</dispatcher>

    <dispatcher>ERROR</dispatcher>

    <dispatcher>ASYNC</dispatcher>

    </filter-mapping>

    <filter-mapping>

    <filter-name>ClickjackFilterSameOrigin</filter-name>

    <url-pattern>/*</url-pattern>

    <dispatcher>FORWARD</dispatcher>

    <dispatcher>REQUEST</dispatcher>

    <dispatcher>ERROR</dispatcher>

    <dispatcher>ASYNC</dispatcher>

    </filter-mapping>

    <filter-mapping>

    <filter-name>GZIPFilter</filter-name>

    <url-pattern>/*</url-pattern>

    <dispatcher>FORWARD</dispatcher>

    <dispatcher>REQUEST</dispatcher>

    <dispatcher>ERROR</dispatcher>

    <dispatcher>ASYNC</dispatcher>

    </filter-mapping>

    <filter-mapping>

    <filter-name>Pretty Filter</filter-name>

    <url-pattern>/*</url-pattern>

    <dispatcher>FORWARD</dispatcher>

    <dispatcher>REQUEST</dispatcher>

    <dispatcher>ERROR</dispatcher>

    <dispatcher>ASYNC</dispatcher>

    </filter-mapping>

    <filter-mapping>

    <filter-name>StaticFileCacheFilter</filter-name>

    <url-pattern>*.css</url-pattern>

    <dispatcher>FORWARD</dispatcher>

    <dispatcher>REQUEST</dispatcher>

    </filter-mapping>

    The reason:

    javax.servlet.ServletException: PWC1232: Exceeded maximum depth for nested request dispatches: 20

    Root cause:

    com.ocpsoft.pretty.PrettyException: Error occurred during canonicalization of request <[/admin/RES_NOT_FOUND]>

    at com.ocpsoft.pretty.PrettyFilter.rewrite(PrettyFilter.java:223)

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

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

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

    at com.blazebit.web.cms.core.system.filter.gzip.GZIPFilter.doFilter(GZIPFilter.java:39)

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

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

    at com.blazebit.web.cms.core.system.filter.security.ClickjackFilter.doFilter(ClickjackFilter.java:40)

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

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

    at com.blazebit.web.cms.core.system.filter.security.HideServerInfoFilter.doFilter(HideServerInfoFilter.java:37)

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

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

    at com.blazebit.web.cms.core.system.filter.HibernateSessionFilter.doFilter(HibernateSessionFilter.java:53)

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

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

    at com.blazebit.blazefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:85)

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

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

    at com.blazebit.web.cms.core.system.filter.security.HttpsFilter.doFilter(HttpsFilter.java:82)

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

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

    at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:785)

    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:649)

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

    at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:454)

    at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:350)

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

    at com.ocpsoft.pretty.PrettyFilter.rewrite(PrettyFilter.java:217)

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

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

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

    at com.blazebit.web.cms.core.system.filter.gzip.GZIPFilter.doFilter(GZIPFilter.java:39)

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

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

    at com.blazebit.web.cms.core.system.filter.security.ClickjackFilter.doFilter(ClickjackFilter.java:40)

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

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

    at com.blazebit.web.cms.core.system.filter.security.HideServerInfoFilter.doFilter(HideServerInfoFilter.java:37)

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

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

    at com.blazebit.web.cms.core.user.filter.LoginRedirectFilter.doFilter(LoginRedirectFilter.java:43)

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

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

    at com.blazebit.web.cms.core.system.filter.HibernateSessionFilter.doFilter(HibernateSessionFilter.java:53)

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

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

    at com.blazebit.blazefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:85)

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

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

    at com.blazebit.web.cms.core.system.filter.security.HttpsFilter.doFilter(HttpsFilter.java:82)

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

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

    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)

    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)

    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)

    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)

    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)

    at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)

    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)

    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)

    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)

    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)

    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)

    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)

    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)

    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)

    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)

    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)

    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)

    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)

    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)

    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)

    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)

    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)

    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)

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

    Caused by: javax.servlet.ServletException: com.ocpsoft.pretty.PrettyException: Error occurred during canonicalization of request <[/admin/RES_NOT_FOUND]>

    at com.blazebit.web.cms.core.system.filter.HibernateSessionFilter.doFilter(HibernateSessionFilter.java:67)

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

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

    at com.blazebit.blazefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:85)

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

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

    at com.blazebit.web.cms.core.system.filter.security.HttpsFilter.doFilter(HttpsFilter.java:82)

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

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

    at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:785)

    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:649)

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

    at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:454)

    at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:350)

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

    at com.ocpsoft.pretty.PrettyFilter.rewrite(PrettyFilter.java:217)

    … 76 more

    Caused by: com.ocpsoft.pretty.PrettyException: Error occurred during canonicalization of request <[/admin/RES_NOT_FOUND]>

    at com.ocpsoft.pretty.PrettyFilter.rewrite(PrettyFilter.java:223)

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

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

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

    at com.blazebit.web.cms.core.system.filter.gzip.GZIPFilter.doFilter(GZIPFilter.java:39)

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

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

    at com.blazebit.web.cms.core.system.filter.security.ClickjackFilter.doFilter(ClickjackFilter.java:40)

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

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

    at com.blazebit.web.cms.core.system.filter.security.HideServerInfoFilter.doFilter(HideServerInfoFilter.java:37)

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

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

    at com.blazebit.web.cms.core.system.filter.HibernateSessionFilter.doFilter(HibernateSessionFilter.java:53)

    … 91 more

    #21273

    RedShadow
    Participant

    The solution is to remove all forward dispatchers of filters which are executed before pretty filter.

    I also think that this only applies to filter which wrap the respone, like GZIPFilter, but i am not sure about that.

    #21274

    RedShadow
    Participant

    I would like to share my final solution with those people who try to setup Prettyfaces and a Gzip Filter:

    Put the filter-mapping element after the prettyfaces filter with all dispatchers.

    <dispatcher>FORWARD</dispatcher>

    <dispatcher>REQUEST</dispatcher>

    <dispatcher>ERROR</dispatcher>

    <dispatcher>ASYNC</dispatcher>

    Request is needed when the request is not mapped in PF and forward of course when it is. Error might be useful too and async should be no problem either.

    The problem with that now is, that the PF-Filter only takes care of the global rewrite rules(correct me if i am wrong). If any rule applies to the current request, the request will be forwarded or redirected else just pushed through the filter chain.

    The main modification you have to make to your gzip filter implementation is, to check wether you response is already a gzip response or not and if yes, then you will probably not want to wrap it again :D

    Here a code snippet to do that:

    boolean compress = true;

    Object wrappedResponse = response;

    while (wrappedResponse instanceof ServletResponseWrapper) {

    if (wrappedResponse instanceof GZIPResponseWrapper) {

    compress = false;

    break;

    } else {

    wrappedResponse = ((ServletResponseWrapper) wrappedResponse).getResponse();

    }

    }

    This modification allows you to use GZIP compression with PF without any errors or endless loops! <3

    #21275

    Thank you for sharing your solution. Maybe this will be useful for others! :)

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

You must be logged in to reply to this topic.

Comments are closed.