我有两个webservice SOAP(Axis2)和另一个类型REST(Jersey 2).
一切正常,但我想把一个放在端口8080上,一个放在端口8081上.
我开始在tomcat/conf文件夹中编辑我的server.xml,用他自己的连接器,引擎和主机创建一个新服务,如下所示:
server.xml:
我在第二个服务上的上下文有问题.当我添加这个并尝试启动Tomcat时,我遇到了这个异常:
GRAVE: A child container failed during start java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[reciver2].StandardHost[localhost].StandardContext[/REST]] at java.util.concurrent.FutureTask.report(Unknown Source) at java.util.concurrent.FutureTask.get(Unknown Source) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:871) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398) 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: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[reciver2].StandardHost[localhost].StandardContext[/REST]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) ... 6 more Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@5e8549c9] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4909) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5039) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ... 6 more Caused by: java.lang.IllegalArgumentException: The main resource set specified [C:\DEV\eclipse\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\webapps\REST] is not valid at org.apache.catalina.webresources.StandardRoot.createMainResourceSet(StandardRoot.java:723) at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:684) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ... 9 more déc. 09, 2015 11:23:28 AM org.apache.catalina.core.ContainerBase startInternal GRAVE: A child container failed during start java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[reciver2].StandardHost[localhost]] at java.util.concurrent.FutureTask.report(Unknown Source) at java.util.concurrent.FutureTask.get(Unknown Source) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916) at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:439) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:769) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.startup.Catalina.start(Catalina.java:625) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:351) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485) Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[reciver2].StandardHost[localhost]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398) 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: org.apache.catalina.LifecycleException: A child container failed during start at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:924) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:871) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ... 6 more déc. 09, 2015 11:23:28 AM org.apache.catalina.startup.Catalina start GRAVE: The required Server component failed to start so Tomcat is unable to start. org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8005]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) at org.apache.catalina.startup.Catalina.start(Catalina.java:625) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:351) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485) Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[reciver2]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:769) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ... 7 more Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[reciver2]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:439) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ... 9 more Caused by: org.apache.catalina.LifecycleException: A child container failed during start at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:924) at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ... 11 more
当我删除上下文tomcat启动并在此端口上侦听.
这是我第一次尝试这样做,我做错了什么,但我不知道我在google和stack上搜索的位置,但我还没有找到解决方案.
我在windows 10,tomcat 8和eclipse Mars上工作.
如果你们其中一个人知道解决方案,我将非常感谢他的帮助.谢谢
您的问题是,您正在尝试从Eclipse IDE中以这种配置启动Tomcat。
Ghayel是正确的,以下是主要原因:
Caused by: java.lang.IllegalArgumentException: The main resource set specified [C:\DEV\eclipse\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\webapps\REST] is not valid at org.apache.catalina.webresources.StandardRoot.createMainResourceSet(StandardRoot.java:723) at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:684) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
有关参考,请参阅Tomcat FAQ中的Eclipse IDE和Eclipse处的Eclipse WebTools Project Tomcat FAQ。
您的问题是由以下两个事实的组合引起的:
默认情况下,Eclipse IDE不使用server.xml
您在IDE中编辑的文件,但是在复制到其他“ CATALINA_BASE”目录中时会对其进行处理。从您的日志消息中,该目录为C:\DEV\eclipse\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\webapps
。
首先,查看conf/server.xml
该目录中的文件。它可能与您编辑的文件不同。
其次,我希望的Eclipse IDE处理server.xml
不支持多个Engine元素。(它可能会支持他们,但如果这样做,我会感到惊讶)。
如果Context
在server.xml中定义了element,则无法启动此上下文会导致整个Tomcat的启动失败。
这是未在中定义Context元素的原因之一server.xml
。
AFAIK(Eclipse中的Tomcat服务器)可以配置为使用不同的CATALINA_BASE目录,并且可以配置为将上下文发布为xml文件(而不是将其放入server.xml
),但是我仍然怀疑这样的配置是否支持多个Engine元素。
我认为您最好的选择是在Eclipse外部配置Tomcat实例,并使用其他工具(例如Apache Ant)在其中打包和部署您的Web应用程序(通过复制文件+依靠自动部署,或通过使用Tomcat Ant任务来完成)将应用程序部署到正在运行的Tomcat实例上)。
如果您不需要这些Web服务位于同一JVM上,只需在Eclipse中配置几个Server实例并并行启动它们即可。(当然,它们的端口号必须不同)。