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

    Problem creating custom filter

    Toni S Newbie

      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