获取NoSuchMethodError:javax.servlet.ServletContext.getVirtualServerName() [英] Getting NoSuchMethodError:javax.servlet.ServletContext.getVirtualServerName()
问题描述
我在Tomcat 8中部署服务时遇到问题。出现以下错误:
I am facing an issue during deployment of a service in Tomcat 8. Getting following error :
引起:java.lang。 NoSuchMethodError:
javax.servlet.ServletContext.getVirtualServerName()Ljava / lang / String;
at org.apache.tomcat.websocket.server.WsServerContainer。(WsServerContainer.java:149)
at org.apache.tomcat.websocket.server.WsSci.init(WsSci.java:131)
at org.apache.tomcat.websocket.server.WsSci.onStartup(WsSci.java:47)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5244)
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 10 more
Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String; at org.apache.tomcat.websocket.server.WsServerContainer.(WsServerContainer.java:149) at org.apache.tomcat.websocket.server.WsSci.init(WsSci.java:131) at org.apache.tomcat.websocket.server.WsSci.onStartup(WsSci.java:47) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5244) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ... 10 more
方法 getVirtualServerName
是在Servlet 3.1中引入的,并在从我的 servlet中解压缩
jar我得到了以下详细信息: MANIFEST.MF
之后-api
Method getVirtualServerName
was introduced in Servlet 3.1 and after extracting MANIFEST.MF
from my servlet-api
jar I got following details :
Specification-Title: Java API for Servlets
Specification-Version: 3.1
Specification-Vendor: Sun Microsystems, Inc.
Implementation-Title: javax.servlet
其中说它有3.1。那么这个错误还有其他原因吗?请帮助
Which says that its having 3.1. So is there any other reason for this error? Please help
推荐答案
检查所有Maven(或等效的)依赖项并确保您 - 或者很可能是另一个依赖项 - 不是拉入3.1版本的 javax.servlet / servlet-api
,它可能优先于你的Tomcat 8中的内容。如果你手动部署,请确保你没有手动将任何servlet-api JAR复制到Tomcat本身。
Check all your Maven (or equivalent) dependencies and make sure that you - or most likely another dependency - are not pulling in a pre-3.1 version of the javax.servlet / servlet-api
that may be taking precedence over what's in your Tomcat 8. If you've manually deployed, make sure you haven't manually copied any servlet-api JARs into Tomcat itself.
参见: https://stackoverflow.com/a/26232535/954442
这篇关于获取NoSuchMethodError:javax.servlet.ServletContext.getVirtualServerName()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!