简体   繁体   English

无法将DispatcherServlet强制转换为具有提供范围的javax.servlet.Servlet

[英]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.

相关问题 ClassCastException:org.springframework.web.servlet.DispatcherServlet无法转换为javax.servlet.Servlet - ClassCastException: org.springframework.web.servlet.DispatcherServlet cannot be cast to javax.servlet.Servlet java.lang.ClassCastException:org.glassfish.jersey.servlet.ServletContainer无法转换为javax.servlet.Servlet - java.lang.ClassCastException: org.glassfish.jersey.servlet.ServletContainer cannot be cast to javax.servlet.Servlet ClassCastException:DispatcherServlet无法强制转换为Servlet - ClassCastException: DispatcherServlet cannot be cast to Servlet Jboss7 EAP:UT010009:类型为org.springframework.web.servlet.DispatcherServlet类型的Servlet远程处理未实现javax.servlet.Servlet - Jboss7 EAP : UT010009: Servlet remoting of type class org.springframework.web.servlet.DispatcherServlet does not implement javax.servlet.Servlet 无法将Maven强制转换为javax.servlet.Filter - Maven cannot be cast to javax.servlet.Filter WebAppInitializer无法强制转换为javax.servlet.ServletContainerInitializer - WebAppInitializer cannot be cast to javax.servlet.ServletContainerInitializer 在Eclipse中,Tomcat 6使用具有“提供”范围的javax.servlet-api 3.0.1 - In eclipse, Tomcat 6 using javax.servlet-api 3.0.1 with 'provided' scope java.lang.ClassCastException:class org.springframework.web.servlet.DispatcherServlet 无法转换为 class jakarta.servlet.Servlet - java.lang.ClassCastException: class org.springframework.web.servlet.DispatcherServlet cannot be cast to class jakarta.servlet.Servlet ClasscastException:MyClass无法转换为javax.servlet.Filter - ClasscastException : MyClass cannot be cast to javax.servlet.Filter java.lang.ClassCastException:无法将spark.servlet.SparkFilter强制转换为javax.servlet.Filter - java.lang.ClassCastException: spark.servlet.SparkFilter cannot be cast to javax.servlet.Filter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM