我在tomcat 7下部署了我的WebServices而没有任何问题。
因为我尝试在tomcat 8下安装新的WebServices实例。 它似乎有一些问题,部署了webapp但是当我尝试时: http://locahost:8080/VICWebServices
它只是返回空白页。
这是我在尝试启动服务器时遇到的catalina错误日志:
30-Jun-2016 10:56:27.149 SEVERE [localhost-startStop-1]
org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/VICWebServices]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:587)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1798)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;
at org.apache.tomcat.websocket.server.WsServerContainer.<init>(WsServerContainer.java:150)
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:5292)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
30-Jun-2016 10:56:27.149 SEVERE [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDescriptor Error deploying configuration descriptor C:\apache-tomcat-8.0.36-AWS-VIC-PROD-2\conf\Catalina\localhost\VICWebServices.xml
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/VICWebServices]]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:729)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:587)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1798)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
30-Jun-2016 10:56:27.150 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDescriptor Deployment of configuration descriptor C:\apache-tomcat-8.0.36-AWS-VIC-PROD-2\conf\Catalina\localhost\VICWebServices.xml has finished in 21,855 ms
30-Jun-2016 10:56:27.152 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-apr-8280"]
30-Jun-2016 10:56:27.162 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-apr-8209"]
30-Jun-2016 10:56:27.166 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 21903 ms
请告诉我这些错误消息。 谢谢 维克
使用 -verbose:class 日志更新
[Loaded javax.servlet.ServletContext from C:\apache-tomcat-8.0.36-AWS-VIC-PROD-2\endorsed\servlet-api.jar]
[Loaded javax.servlet.ServletContextAttributeListener from C:\apache-tomcat-8.0.36-AWS-VIC-PROD-2\endorsed\servlet-api.jar]
[Loaded javax.servlet.ServletContextListener from C:\apache-tomcat-8.0.36-AWS-VIC-PROD-2\endorsed\servlet-api.jar]
[Loaded com.sun.xml.ws.transport.http.servlet.WSServletContextListener from C:\apache-tomcat-8.0.36-AWS-VIC-PROD-2\endorsed\webservices-rt.jar]
[Loaded javax.servlet.ServletContextEvent from C:\apache-tomcat-8.0.36-AWS-VIC-PROD-2\endorsed\servlet-api.jar]
[Loaded javax.servlet.ServletContextAttributeEvent from C:\apache-tomcat-8.0.36-AWS-VIC-PROD-2\endorsed\servlet-api.jar]
答案 0 :(得分:0)
消息是
NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;
这意味着您针对包含此方法的servlet库版本编译了代码,但部署WAR文件的服务器正在运行(可能更早)不包含此方法的版本。
确保在构建和部署环境中使用相同的API版本。
答案 1 :(得分:0)
最可能的原因是你在WAR中打包了旧版本的API(tomcat应该忽略它),或者你已经在tomcat / lib中放置了这样的版本。
您可以通过运行带有详细类加载的tomcat来识别有问题的JAR。这可以通过将-verbose:class
添加到JVM参数来完成。您可以通过将其添加到env变量JAVA_OPTS:
export JAVA_OPTS=-verbose:class
set JAVA_OPTS=-verbose:class
然后当你启动tomcat时,你会得到很多类似于:
的输出[Loaded javax.websocket.server.ServerEndpointConfig$Builder from file:/C:/Users/xxx/Downloads/software/apache-tomcat-8.0.36/apache-tomcat-8.0.36/lib/websocket-api.jar]
[Loaded javax.websocket.server.ServerEndpointConfig from file:/C:/Users/xxx/Downloads/software/apache-tomcat-8.0.36/apache-tomcat-8.0.36/lib/websocket-api.jar]
[Loaded org.apache.tomcat.websocket.server.DefaultServerEndpointConfigurator from file:/C:/Users/xxx/Downloads/software/apache-tomcat-8.0.36/apache-tomcat-8.0.36/lib/tomcat-
[Loaded javax.websocket.server.DefaultServerEndpointConfig from file:/C:/Users/xxx/Downloads/software/apache-tomcat-8.0.36/apache-tomcat-8.0.36/lib/websocket-api.jar]
[Loaded org.apache.tomcat.websocket.pojo.PojoMethodMapping from file:/C:/Users/xxx/Downloads/software/apache-tomcat-8.0.36/apache-tomcat-8.0.36/lib/tomcat-websocket.jar]
然后从哪个jar中查找正在加载的servlet上下文,如果它不是来自tomcat或修复它,则将其删除。
答案 2 :(得分:0)
您必须使用支持tomcat 8的最新jar更新旧罐子 例如,一些restfull api只支持tomcat 7而不是8 所以你必须把lates jars
jersey 1.7支持tomcat 7及以下