tomcat启动的时候报错Failed to start component

时间:2021-10-05 10:48:14

在idea中运行tomcat时,遇到异常,异常信息如下:

16-Jan-2018 16:33:37.325 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDescriptor Deploying configuration descriptor C:\Users\Administrator\.IntelliJIdea2017.1\system\tomcat\Unnamed_xxx_6\conf\Catalina\localhost\AAA.xml

16-Jan-2018 16:33:37.331 警告 [localhost-startStop-1] org.apache.catalina.startup.SetContextPropertiesRule.begin [SetContextPropertiesRule]{Context} Setting property 'debug' to '0' did not find a matching property.

16-Jan-2018 16:33:37.336 严重 [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[/AAA]]

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)

at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753)

at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:729)

at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)

at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:621)

at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1835)

at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)

at java.util.concurrent.FutureTask.run(FutureTask.java:266)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

at java.lang.Thread.run(Thread.java:745)

Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@1f063757]

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)

at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4969)

at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5102)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

... 10 more

Caused by: java.lang.IllegalArgumentException: The main resource set specified [G:\AAA] is not valid

at org.apache.catalina.webresources.StandardRoot.createMainResourceSet(StandardRoot.java:746)

at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:704)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

... 13 more

16-Jan-2018 16:33:37.338 严重 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDescriptor Error deploying configuration descriptor C:\Users\Administrator\.IntelliJIdea2017.1\system\tomcat\Unnamed_xxx_6\conf\Catalina\localhost\AAA.xml

java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/AAA]]

at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:757)

at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:729)

at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)

at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:621)

at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1835)

at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)

at java.util.concurrent.FutureTask.run(FutureTask.java:266)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

at java.lang.Thread.run(Thread.java:745)

  网上各种答案:1)tomcat与jdk版本不匹配;2)maven版本冲突;3)web.zml中配置错误;4)tomcat有缓存.........我都尝试了都没有解决我的问题。

  由于我在tomcat中配置了虚拟路径(什么是虚拟路劲,怎么设置请看http://blog.csdn.net/zjml2412/article/details/49962939),就是在tomcat的安装目录conf\Catalina\localhost下新建了一个配置文件AAA.xml文件,文件具体内容为:

    <?xml version="1.0" encoding="UTF-8"?>

    <Context docBase="G:/AAA" reloadable="true" debug="0" path="/AAA"/>

  其中“G:/AAA”代表我的电脑磁盘的G盘有个AAA文件,tomcat在启动的时候会加载“G:/AAA”文件夹(文件),以便可以在网络上使用"/AAA"访问,所以说如果G盘没有AAA文件夹(文件),tomcat启动时会出现上面的异常。

  所以说出现上面的异常,1)如果你配置过虚拟路径,并且项目中要用到虚拟路径,那么请先在对应的”G”盘创建”AAA”文件;2)如果没有配置过虚拟路劲,出现上面的异常,你可以将conf\Catalina\localhost的文件删除;实在不行,网上下载一个新的tomcat部署项目应该就好了。