4 Replies Latest reply on Nov 4, 2008 12:59 PM by kokice

    Problem creating custom filter

    kokice

      Hi there.


      I'm trying to create a custom filter. My goal is a filter which is run on every request. This is a simplified version of my filter:



      @Startup
      @Name(value = "TestFilter")
      @Scope(value = ScopeType.APPLICATION)
      @BypassInterceptors
      @Filter(within = "org.jboss.seam.web.ContextFilter")
      public class TestFilter extends AbstractFilter {
      
          @Logger
          private static Log log;
      
          @In(create = true, required = true)
          private RegService regservice;
      
          public void doFilter(final ServletRequest request,
                  final ServletResponse response, final FilterChain filterChain)
                          throws IOException, ServletException {
               // some code
               filterChain.doFilter(request, response);
          }
      



      My RegService is a stateless Session bean. But i'm getting this, not on every request, but quite often:



      23:42:50,301 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
      java.lang.NullPointerException
              at org.jboss.seam.contexts.Contexts.destroy(Contexts.java:241)
              at org.jboss.seam.contexts.Lifecycle.endCall(Lifecycle.java:95)
              at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:122)
              at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166)
              at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)
              at se.test.TestFilter_$$_javassist_0.doFilter(TestFilter_$$_javassist_0.java)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
              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.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
              at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
              at java.lang.Thread.run(Thread.java:613)
      



      Why this? What am I missing here?


      And is my custom filter correct?


      Any help or hints are appreciated. ;)


      BR

        • 1. Re: Problem creating custom filter
          atamur

          looking into source this means that session context thread local is null ... which is quite strange ... i think it would be helpful if you mentioned your seam version

          • 2. Re: Problem creating custom filter
            kokice

            Hi Ilya,


            of course. Stupid of me. I'm running the latest version, which is 2.1.0. I have not downloaded the SP1 release though, however I suspect this has to do with something else.

            • 3. Re: Problem creating custom filter
              tazman

              Can you annotate a class with @BypassInterceptors and use injection in it (as you do for RegService)?

              • 4. Re: Problem creating custom filter
                kokice

                Tom Claire wrote on Nov 04, 2008 10:46:


                Can you annotate a class with @BypassInterceptors and use injection in it (as you do for RegService)?



                Hi Tom,


                you are probably right, that is not possible. However, even if I remove that, it still does not work.


                The interesting part is that it actually works if I find my bean with a regular JNDI-lookup. Then it works.


                Someone told me that this is a bug in JBoss 4.x. Maybe someone can confirm this?