[Solved] spring-security-web classes are not available. You need these to use filter-chain-map

Recently I downloaded the latest Spring Tool Suite (STS) with Java 8 SE support. My intention was to give it a try to Stream API on my personal project. An error was shown on the spring security configuration XML once I imported it to the STS.

The STS displayed following configuration error:

“ spring-security-web classes are not available. You need these to use <filter- chain-map>”

I visited  the Google search page, googled the error. This was what I found.

FilterChainProxy class (org.springframework.security.web.FilterChainProxy) of spring security artifact  imports few javax.servlet classes. The pom.xml didn’t have servlet library dependency in it.

I added following servlet dependency to it.


After maven install, the error was  gone, so I decided to initiate the app.

The console displayed following exception  long before I could see the index page:

“ServletDispatcher cannot be cast to Javax.servlet.Servlet exception”

Adding servlet-api artifact will include servlet JAR along with the container specific servlet libraries, which would load different servlet API class-loaders at run time and causes the above exception.  The servlet artifact is only needed at compilation in this case, so setting the scope to ‘provided’ will resolve the issue.

About dependency scope from Maven doc:

  • compile
    This is the default scope, used if none is specified. Compile dependencies are available in all classpaths of a project. Furthermore, those dependencies are propagated to dependent projects.
  • provided
    This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. This scope is only available on the compilation and test classpath, and is not transitive.


The final dependency definition for javax.servlet with ‘provided’ scope






Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s