简体   繁体   English

Spring Tomcat7错误“org.springframework.web.SpringServletContainerInitializer无法强制转换为javax.servlet.ServletContainerInitializer”

[英]Spring Tomcat7 error “org.springframework.web.SpringServletContainerInitializer cannot be cast to javax.servlet.ServletContainerInitializer”

I am getting below error while starting the Tomcat7 server. 我在启动Tomcat7服务器时遇到错误。

org.springframework.web.SpringServletContainerInitializer cannot be cast to javax.servlet.ServletContainerInitializer

I am just curious to find the root cause of this issue. 我很想知道这个问题的根本原因。 In what scenario this error happens? 在什么情况下会发生此错误? I didn't get the error when I use Tomcat Enterprise Edition(TomEE) 我使用Tomcat企业版(TomEE)时没有收到错误

In my project ServletContainerInitializer is getting loaded from javeee-api-7.0.jar 在我的项目中,ServletContainerInitializer从javeee-api-7.0.jar加载

I have tried excluding the javax.servlet-api which is getting loaded from javeee-api but thats not working 我已经尝试排除从javeee-api加载的javax.servlet-api,但那不起作用

添加javeee-api-7.0.jar,它适合我。

We encountered this case in our project that contained loads of legacy code that was obviously not really well maintained. 我们在项目中遇到了这种情况,其中包含很多遗留代码,显然没有很好地维护。

We solved it by analyzing all dependencies inside all pom.xml files. 我们通过分析所有pom.xml文件中的所有依赖项来解决它。 For this issue particularly, what we did was to exclude javax.servlet api because there was a conflicting version that loaded and caused the cast error. 特别是对于这个问题,我们所做的是排除javax.servlet api,因为存在加载的冲突版本并导致了转换错误。

If you use eclipse, when opening the pom.xml files, you can check the dependencies with the Dependency Hierarchy tab at the bottom. 如果使用eclipse,则在打开pom.xml文件时,可以使用底部的Dependency Hierarchy选项卡检查依赖项。 There you can use the filter to see all servlet jars versions, and the top-level dependency that uses them. 在那里,您可以使用过滤器查看所有servlet jar版本以及使用它们的顶级依赖项。 You can then exclude the problematic ones by right clicking on them and selecting "Exclude Maven Artifact..." And then the obvious: save your pom.xml, eventually repeat for other projects/modules, update your maven project configuration and finally build/install/run to see if the problem is fixed. 然后你可以通过右键单击它们并选择“Exclude Maven Artifact ...”来排除有问题的那些,然后显而易见:保存你的pom.xml,最后重复其他项目/模块,更新你的maven项目配置,最后构建/安装/运行以查看问题是否已修复。

Hope that helps! 希望有所帮助!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 org.springframework.web.SpringServletContainerInitializer无法转换为javax.servlet.ServletContainerInitializer — Eclipse Spring项目 - org.springframework.web.SpringServletContainerInitializer cannot be cast to javax.servlet.ServletContainerInitializer — Eclipse Spring Project wildfly 10 - javax.servlet.ServletContainerInitializer:提供者 org.springframework.web.SpringServletContainerInitializer 不是子类型 - wildfly 10 - javax.servlet.ServletContainerInitializer: Provider org.springframework.web.SpringServletContainerInitializer not a subtype SpringServletContainerInitializer无法强制转换为javax.servlet.ServletContainerInitializer - SpringServletContainerInitializer cannot be cast to javax.servlet.ServletContainerInitializer WebAppInitializer无法强制转换为javax.servlet.ServletContainerInitializer - WebAppInitializer cannot be cast to javax.servlet.ServletContainerInitializer 在 WebSphere 上将应用程序升级到 Spring 5 时出错:Provider org.springframework.web.SpringServletContainerInitializer not a subtype - Error upgrading application to Spring 5 on WebSphere: Provider org.springframework.web.SpringServletContainerInitializer not a subtype ClassCastException:org.springframework.web.servlet.DispatcherServlet无法转换为javax.servlet.Servlet - ClassCastException: org.springframework.web.servlet.DispatcherServlet cannot be cast to javax.servlet.Servlet org.springframework.web.filter.CharacterEncodingFilter无法转换为javax.servlet.Filter - org.springframework.web.filter.CharacterEncodingFilter cannot be cast to javax.servlet.Filter org.springframework.web.filter.HiddenHttpMethodFilter无法强制转换为javax.servlet.Filter - org.springframework.web.filter.HiddenHttpMethodFilter cannot be cast to javax.servlet.Filter Spring MVC错误:org.springframework.web.servlet.DispatcherServlet noHandlerFound - Spring MVC Error: org.springframework.web.servlet.DispatcherServlet noHandlerFound 更新到Spring 2.5.5会导致javax.servlet.UnavailableException:org.springframework.web.struts.DelegatingTilesRequestProcessor - Updating to Spring 2.5.5 causes a javax.servlet.UnavailableException: org.springframework.web.struts.DelegatingTilesRequestProcessor
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM