[英]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. 我在myeclipse上运行Spring Security Web应用程序。 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.
如果是这样,则可能是存在类加载器问题,并且您有两个javax.servlet.Servlet类实例,它们是由不同的类加载器加载的。 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.
如果您有GenericServlet的实例,则它必须可转换为它的超类之一,但是,某种程度上,VM正在尝试将其转换为超类的不同负载。 If the same class (by name) is loaded by two different class loaders, they end up as two different classes in the VM.
如果两个不同的类加载器加载了相同的类(按名称),则它们最终将成为VM中的两个不同的类。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.