SEVERE: Exception springSecurityFilterChain… ClassCastException… DelegatingFilterProxy cannot be cast

自作多情 提交于 2019-12-05 06:49:33

One of your dependencies are including a servlet-api into your war file which causes that behavior. Using mvn dependency:tree, you can find out which of your dependency is that. After that you need to exclude the servlet-api as follows:

<dependency>
  <groupId>[VALUE]</groupId>
  <artifactId>[VALUE]</artifactId>
  <version>[VALUE]</version>
  <exclusions>
    <exclusion>
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
    </exclusion>
  </exclusions>
</dependency>

You need to do this for other servlet-api's (e.g. org.mortbay.jetty:servlet-api, ..) as well.

I could fix this by removing servlet-api.jar from my deployment assembly (in eclipse)

my-web-project-> properties -> Deployment Assembly

and removing it. Others state that on maven projects the scope of the servlet-api dependency must be set to 'provided'

I got a similar problem when I added the dependency for CXF. I tried the above recommended way of excluding javax.servlet from that dependency but it didn't work- but adding provided solved it. It could be a different case for you but worth a try.

<dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-bundle-jaxrs</artifactId>
        <version>2.2.9</version>
        <scope>provided</scope>
    </dependency>

If I answered your question please mark it so. ;)

Similiar issue was resolved by excluding geronimo.

        <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http-jetty</artifactId>
        <version>3.0.3</version>
        <exclusions>
            <exclusion>
                <groupId>org.apache.geronimo.specs</groupId>
                <artifactId>geronimo-servlet_2.5_spec</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.apache.geronimo.specs</groupId>
                <artifactId>geronimo-servlet_3.0_spec</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

Determinig which jar files contained the error uas found by scanning each jar file in the WEB-INF/lib folder for the classes it contained. I.e.

jar tvf <jar-file>

probably in web.xml you configure

<servlet>
    <servlet-name>springSecurityFilterChain</servlet-name>
    <servlet-class>org.springframework.web.filter.DelegatingFilterProxy</servlet-class>
</servlet>

but it is filter. so change servlet as filter.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!