0

We are trying to introduce Spring Security 4.0.2 into a Spring MVC application which uses Spring 4.2.3 but also is running on servlet 2.5. I am having trouble configuring Security:

Caused by: java.lang.ClassNotFoundException: javax.servlet.FilterRegistration$Dynamic

I believe this class is only in Servlet 3.0. Is it possible to use Spring Security 4.0 with Servlet 2.5? Or should we regress to Security 3.2?

badgerduke
  • 1,013
  • 5
  • 16
  • 28
  • We use Spring Security `4.0.3.RELEASE` with Spring `4.2.4.RELEASE` and Servlet API `2.5` and don't face any problems either at compilation or during application start up or at runtime. I have created a [small sample](https://github.com/manish-in-java/stackoverflow-questions/tree/master/35732187) from our production application that you can check. You will see that it compiles and loads fine. If you could post a similar minimum sample that demonstrates the problem, someone can check. – manish Mar 03 '16 at 04:44

2 Answers2

0

My suspicion is you are using Jetty and this explains your situation.

The javax.servlet.FilterRegistration class was introduced in Servlet 3.0. This exception suggests that you have still libraries of an older Servlet API version in your runtime classpath which got precedence in classloading.

Community
  • 1
  • 1
syncdk
  • 2,820
  • 3
  • 25
  • 31
0

Apparently, Java configuration demands this class. I used the old XML configuration and things worked fine.

badgerduke
  • 1,013
  • 5
  • 16
  • 28