Announcement Announcement Module
Collapse
No announcement yet.
Using DelegatingFilterProxy with autowired dependency Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using DelegatingFilterProxy with autowired dependency

    Hi,

    I have a filter defined in web.xml as
    Code:
    <filter>
            <filter-name>sampleSpringFilter</filter-name>
            <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
        </filter>
        
        <filter-mapping>
    		<filter-name>sampleSpringFilter</filter-name>
    		<url-pattern>/api/foo/*</url-pattern>
        </filter-mapping>
    The class sampleSpringFilter is defined as:
    Code:
    @Component("sampleSpringFilter")
    public class SampleSpringFilter implementes Filter
    {
    
      @Inject
      private ITestService testService;
    
     @Override
    	public void doFilter(ServletRequest request, ServletResponse response,
    			FilterChain chain) throws IOException, ServletException {
    --
    }
    }
    When I am trying to deploy my webapp in tomcat 7, application context is not able to find sampleSpringFilter.
    I don't want to use xml based bean definition for sampleSpringFilter.

    Please help me resolving this issue.
    Last edited by omanand; Oct 25th, 2012, 12:29 AM.

  • #2
    Please use [ code][/code ] tags when posting code/xml/stacktraces, that way it remains readable...

    Only specifing the filter and adding @Component is pretty useless... If you don't scan for components (component-scanning) nothing is going to happen. Also the compoment has to be in the root context (ContextLoaderListener) and not in the child context (DispatcherServlet).

    Comment


    • #3
      Thanks Marten. I had made a mistake of specifying component-scan in the child context (DispatcherServlet).

      Comment

      Working...
      X