总体而言,我对Gradle还是个新手,所以希望这不是一个愚蠢的问题,但我在运行容器时遇到了这个问题(这会立即导致容器崩溃)。
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.apache.catalina.authenticator.AuthenticatorBase.startInternal(AuthenticatorBase.java:1319)
The following method did not exist:
'java.lang.String javax.servlet.ServletContext.getVirtualServerName()'
The method's class, javax.servlet.ServletContext, is available from the following locations:
jar:file:/app/lib/servlet-api-2.5-6.1.14.jar!/javax/servlet/ServletContext.class
jar:file:/app/lib/javax.servlet-api-4.0.1.jar!/javax/servlet/ServletContext.class
jar:file:/app/lib/tomcat-embed-core-9.0.62.jar!/javax/servlet/ServletContext.class
jar:file:/app/lib/servlet-api-2.5-20081211.jar!/javax/servlet/ServletContext.class
The class hierarchy was loaded from the following locations:
javax.servlet.ServletContext: file:/app/lib/servlet-api-2.5-6.1.14.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of javax.servlet.ServletContext
我试过加上
configurations.all {
exclude group: '', module: 'servlet-api'
}
但它会删除servlet api的其他版本(错误指定它在servlet-api-2.5 - 6.1.14.jar中查找,但它删除了servlet-api-2.5 - 20081211.jar,因为构建和运行后的错误输出现在是:
The method's class, javax.servlet.ServletContext, is available from the following locations:
jar:file:/app/lib/servlet-api-2.5-6.1.14.jar!/javax/servlet/ServletContext.class
jar:file:/app/lib/javax.servlet-api-4.0.1.jar!/javax/servlet/ServletContext.class
jar:file:/app/lib/tomcat-embed-core-9.0.62.jar!/javax/servlet/ServletContext.class
The class hierarchy was loaded from the following locations:
javax.servlet.ServletContext: file:/app/lib/servlet-api-2.5-6.1.14.jar
我已经运行了一个依赖性任务,并且servlet-api依赖于org.apache.hadoop:hadoop-core:1.2.1
解决这个问题的最好方法是什么?我试过排除并给出确切的版本号,但似乎不起作用。我也试过添加新版本的hadoop核心依赖项(它将与新版本的servlet-api捆绑在一起。因为我相信我需要3.1+(我有2.5)),但似乎也不起作用
1条答案
按热度按时间5n0oy7gb1#
我认为这个错误
以下方法不存在:
是因为servlet API的版本早于3.1,并且getVirtualServerName()方法是在3.1和更高版本中引入的。