3 Replies Latest reply on Jul 4, 2009 3:41 PM by nbelaevski

    Filters not working when using RichFaces

    crispyozau

      Hi,

      I have a filter that I've been using successfully for years, but now I am using RichFaces (3.3.1GA) I can no longer use it.

      The problem seems to be related to the filter chaining but that's just a guess. Maybe I am just doing something stupid.

      Below is my filter code. As you can see it simply checks is the session contains a user id attribute, if found then it just calls the filter chain, if not set then it forwards to the login page:

      public void doFilter(ServletRequest req, ServletResponse res,
      FilterChain chain) throws IOException, ServletException {

      Log.info("Running login security check filter");
      HttpSession session = ((HttpServletRequest) req).getSession();
      if (session != null && session.getAttribute(Constants.Key_uid) != null) {
      Log.debug("Logged in user is: "
      + session.getAttribute(Constants.Key_uid));
      chain.doFilter(req, res);
      } else {
      Log.info("Not logged in");
      RequestDispatcher rd
      =req.getRequestDispatcher(ConfigUtils.getParameter(Constants.Param_LoginPage));
      rd.forward(req, res);
      }
      }


      The stack trace is showing some strange errors:

      INFO: Not logged in
      04/07/2009 4:42:18 PM org.apache.catalina.core.ApplicationDispatcher invoke
      SEVERE: Servlet.service() for servlet Faces Servlet threw exception
      javax.faces.FacesException: Error decode resource data
      at org.ajax4jsf.resource.ResourceBuilderImpl.decrypt(ResourceBuilderImpl.java:627)
      at org.ajax4jsf.resource.ResourceBuilderImpl.getResourceDataForKey(ResourceBuilderImpl.java:369)
      at org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.java:156)
      at org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.java:141)
      at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:488)
      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:654)
      at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445)
      at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)
      at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)
      at com.trm.security.filters.LoginCheckFilter.doFilter(LoginCheckFilter.java:56)
      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:230)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      at java.lang.Thread.run(Unknown Source)
      Caused by: java.util.zip.DataFormatException: unknown compression method
      at java.util.zip.Inflater.inflateBytes(Native Method)
      at java.util.zip.Inflater.inflate(Unknown Source)
      at java.util.zip.Inflater.inflate(Unknown Source)
      at org.ajax4jsf.resource.ResourceBuilderImpl.decrypt(ResourceBuilderImpl.java:621)
      ... 23 more

        • 1. Re: Filters not working when using RichFaces
          nbelaevski

          Hi,

          Resource requests should not be passed through your filter.

          • 2. Re: Filters not working when using RichFaces
            crispyozau

            Hi nbelaevski, thanks for your reply.

            That makes sense because usually I will have the url-pattern set to /context/* but since I started using RichFaces in my app this filter never gets called if I use that url pattern. If I set the url-pattern to /* the filter gets executed but but I'm ending up with this issue.

            My filter is first in the web.xml so it should be called first, but I'm only getting this issue when I started using RichFaces.

            Confused!

            • 3. Re: Filters not working when using RichFaces
              nbelaevski

              Resources data (colors, size, etc.) is encoded into URI, for example: /richfaces-demo/a4j/g/3_3_2-SNAPSHOTorg.richfaces.renderkit.html.images.EditIcon/DATB/eAFjYPgPAAECAQA_.jsf (after DATB marker). Looks like, your filter strips this data, that's why this exception happens. You can configure mapping for resources in web.xml and then make your filter bypass such requests.