Anthony
Anthony

Reputation: 91

Filter servlet with Spring : HTTP 500 error

I followed this article : Spring and servlet filters to add a filter on a specific URL.

I added my 'foo' class, which implements 'Filter' interface.

But when I access to my specific URL, an Java exception is catch :

java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?

My technical environment is :

Thank you very much for your help,

Regards,

Anthony

Upvotes: 1

Views: 1036

Answers (1)

skaffman
skaffman

Reputation: 403531

DelegatingFilterProxy works by delegating the work of the filter to a bean in the root webapp spring context. If you're getting that error, then you haven't defined one.

You need to make sure something like the following is in your web.xml:

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>  

This will obtain the context's bean definitions from /WEB-INF/application.xml

Upvotes: 1

Related Questions