2 Replies Latest reply on Sep 6, 2010 7:09 PM by kragoth

    get a session seam variable from servlet filter

      Hi, I am trying to get a session seam variable from servlet filter

         @Name("mybean")
         @Scope(ScopeType.SESSION)

         public class Mybean{
           private String var; 
         }

      and the servlet Filter :

         public class MyFilter implements Filter {
        
           MyBean bean;

             @Override
             public void destroy() {
              // TODO Auto-generated method stub
             }

             @Override
             public void doFilter(ServletRequest request, ServletResponse response,   
             FilterChain    chain) throws IOException,
                  ServletException {
          
           this.bean = org.jboss.seam.Component.getInstance("mybean");

              chain.doFilter(request, response);
          }

          @Override
          public void init(FilterConfig filterConfig) throws ServletException {      
          }
         }


      But i got an exception no active context.

      Anyone can help me?

      Thanks.
        • 1. Re: get a session seam variable from servlet filter
          ianmichell

          I get the same thing. Generally in a seam application it is recommended that you use the filter annotations, in my primary seam application this works perfectly... I have another war file with an old spring project that I am integrating with seam. It uses acegi for security and although I have gotten it to bootstrap, I get the same error as you when logging in.


          I am trying to expose a few of the classes it uses as seam components to see if that makes a difference, otherwise I think another way around it is to extends the old filter and use the annotations seam provides.

          • 2. Re: get a session seam variable from servlet filter
            kragoth

            What are the annotations on your filter?


            The Seam example in the doco is like this:


            @Startup
            @Scope(APPLICATION)
            @Name("org.jboss.seam.web.multipartFilter")
            @BypassInterceptors
            @Filter(within="org.jboss.seam.web.ajax4jsfFilter")
            public class MultipartFilter extends AbstractFilter {
            



            What have you got?