异常org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.configurecontext
欢迎使用Markdown编辑器
环境描述:
spring-boot-starter-parent版本2.4.4
问题描述,如下:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.configurecontext(TomcatServletwebServerFactory.java:366)
The following method did not exist:
org.apache.catalina.Context.addServletContainerInitializer(Ljavax/servlet/ServletContainerInitializer;Ljava/util/Set;)V
The method's class, org.apache.catalina.Context, is available from the following locations:
jar:file:/home/ldnctisvctrbdve1/dp-engine.jarl/B00T-INF/lib/tomcat-embed-core-10.8.12. jarl/org/apache/catalina/Context.class
The class hierarchy was loaded from the following locations:
org.apache.catalina.Context: jar:file:/home/ldnctisvctrbdve1/dp-engine.jar!/B00T-INF/lib/tomcat-embed-core-10.e.12.jarl/
解决方式
问题产生缘于我们本次升级系统依赖采用了Apache Tomcat Embed 10.0.12版本,自从Tomcat10(Jakarta Servlet 5.0)之后,老版本使用的包路径:javax.servlet.* 被修改了,新版本对应的包路径为:jakarta.servlet.*,然而却有很少的第三方jar包对tomcat新版本做出及时的响应和更新,所以,我们对于本次依赖升级的解决办法是降低spring内嵌tomcat的版本,使用9.0.54版本
完成异常信息,如下: