简体   繁体   中英

DispatcherServlet cannot be cast to javax.servlet.Servlet with scope provided

This question is perhaps a duplicate one but since I am not able to find a concrete resolution hence posting it again, am getting this error:

DispatcherServlet cannot be cast to javax.servlet.Servlet

even with scope provided in the dependency as below

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.0.1</version>
    <scope>provided</scope>

</dependency>

I am running a spring security web application on myeclipse. I have also tried all the other scopes but no help.

Just a thought, but I assume you're getting this error when running the application on a server. If so, it may be that there is a class loader problem and you have two instances of the javax.servlet.Servlet class, loaded by different class loaders. If you have an instance of GenericServlet then it must be castable to one of its superclasses but, somehow, the VM is trying to cast it to a different load of the superclass. If the same class (by name) is loaded by two different class loaders, they end up as two different classes in the VM.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM