一、問題描述:
今天用myeclipse寫了個小demo,而後用Tomcat7 部署了,接着點擊啓動服務器,服務器竟然報錯:
嚴重: Error starting static Resources
java.lang.IllegalArgumentException
: Document base H:\software\apache-tomcat\apache-tomcat-7.0.52\webapps\lemon does not exist or is not a readable directory
at org.apache.naming.resources.FileDirContext.setDocBase(
FileDirContext.java:136
)
at org.apache.catalina.core.StandardContext.resourcesStart(
StandardContext.java:5089
)
at org.apache.catalina.core.StandardContext.startInternal(
StandardContext.java:5269
)
at org.apache.catalina.util.LifecycleBase.start(
LifecycleBase.java:150
)
at org.apache.catalina.core.ContainerBase$StartChild.call(
ContainerBase.java:1559
)
at org.apache.catalina.core.ContainerBase$StartChild.call(
ContainerBase.java:1549
)
at java.util.concurrent.FutureTask.run(
FutureTask.java:262
)
at java.util.concurrent.ThreadPoolExecutor.runWorker(
ThreadPoolExecutor.java:1145
)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(
ThreadPoolExecutor.java:615
)
at java.lang.Thread.run(
Thread.java:745
)
四月 22, 2017 6:57:41 下午 org.apache.catalina.core.ContainerBase startInternal
嚴重: A child container failed during start
java.util.concurrent.ExecutionException
:
org.apache.catalina.LifecycleException
: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/lemon]]
at java.util.concurrent.FutureTask.report(
FutureTask.java:122
)
at java.util.concurrent.FutureTask.get(
FutureTask.java:188
)
at org.apache.catalina.core.ContainerBase.startInternal(
ContainerBase.java:1123
)
at org.apache.catalina.core.StandardHost.startInternal(
StandardHost.java:799
)
at org.apache.catalina.util.LifecycleBase.start(
LifecycleBase.java:150
)
at org.apache.catalina.core.ContainerBase$StartChild.call(
ContainerBase.java:1559
)
at org.apache.catalina.core.ContainerBase$StartChild.call(
ContainerBase.java:1549
)
at java.util.concurrent.FutureTask.run(
FutureTask.java:262
)
at java.util.concurrent.ThreadPoolExecutor.runWorker(
ThreadPoolExecutor.java:1145
)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(
ThreadPoolExecutor.java:615
)
at java.lang.Thread.run(
Thread.java:745
)
Caused by:
org.apache.catalina.LifecycleException
: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/lemon]]
at org.apache.catalina.util.LifecycleBase.start(
LifecycleBase.java:154
)
... 6 more
Caused by:
org.apache.catalina.LifecycleException
: Error in resourceStart()
at org.apache.catalina.core.StandardContext.startInternal(
StandardContext.java:5270
)
at org.apache.catalina.util.LifecycleBase.start(
LifecycleBase.java:150
)
... 6 more
四月 22, 2017 6:57:41 下午 org.apache.catalina.core.ContainerBase startInternal
嚴重: A child container failed during start
java.util.concurrent.ExecutionException
:
org.apache.catalina.LifecycleException
: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
at java.util.concurrent.FutureTask.report(
FutureTask.java:122
)
at java.util.concurrent.FutureTask.get(
FutureTask.java:188
)
at org.apache.catalina.core.ContainerBase.startInternal(
ContainerBase.java:1123
)
at org.apache.catalina.core.StandardEngine.startInternal(
StandardEngine.java:300
)
at org.apache.catalina.util.LifecycleBase.start(
LifecycleBase.java:150
)
at org.apache.catalina.core.StandardService.startInternal(
StandardService.java:443
)
at org.apache.catalina.util.LifecycleBase.start(
LifecycleBase.java:150
)
at org.apache.catalina.core.StandardServer.startInternal(
StandardServer.java:731
)
at org.apache.catalina.util.LifecycleBase.start(
LifecycleBase.java:150
)
at org.apache.catalina.startup.Catalina.start(
Catalina.java:689
)
at sun.reflect.NativeMethodAccessorImpl.invoke0(
Native Method
)
at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:57
)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:43
)
at java.lang.reflect.Method.invoke(
Method.java:606
)
at org.apache.catalina.startup.Bootstrap.start(
Bootstrap.java:321
)
at org.apache.catalina.startup.Bootstrap.main(
Bootstrap.java:455
)
Caused by:
org.apache.catalina.LifecycleException
: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
at org.apache.catalina.util.LifecycleBase.start(
LifecycleBase.java:154
)
at org.apache.catalina.core.ContainerBase$StartChild.call(
ContainerBase.java:1559
)
at org.apache.catalina.core.ContainerBase$StartChild.call(
ContainerBase.java:1549
)
at java.util.concurrent.FutureTask.run(
FutureTask.java:262
)
at java.util.concurrent.ThreadPoolExecutor.runWorker(
ThreadPoolExecutor.java:1145
)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(
ThreadPoolExecutor.java:615
)
at java.lang.Thread.run(
Thread.java:745
)
Caused by:
org.apache.catalina.LifecycleException
: A child container failed during start
at org.apache.catalina.core.ContainerBase.startInternal(
ContainerBase.java:1131
)
at org.apache.catalina.core.StandardHost.startInternal(
StandardHost.java:799
)
at org.apache.catalina.util.LifecycleBase.start(
LifecycleBase.java:150
)
... 6 more
四月 22, 2017 6:57:41 下午 org.apache.catalina.startup.Catalina start
嚴重: 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:689
)
at sun.reflect.NativeMethodAccessorImpl.invoke0(
Native Method
)
at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:57
)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:43
)
at java.lang.reflect.Method.invoke(
Method.java:606
)
at org.apache.catalina.startup.Bootstrap.start(
Bootstrap.java:321
)
at org.apache.catalina.startup.Bootstrap.main(
Bootstrap.java:455
)
Caused by:
org.apache.catalina.LifecycleException
: Failed to start component [StandardService[Catalina]]
at org.apache.catalina.util.LifecycleBase.start(
LifecycleBase.java:154
)
at org.apache.catalina.core.StandardServer.startInternal(
StandardServer.java:731
)
at org.apache.catalina.util.LifecycleBase.start(
LifecycleBase.java:150
)
... 7 more
Caused by:
org.apache.catalina.LifecycleException
: Failed to start component [StandardEngine[Catalina]]
at org.apache.catalina.util.LifecycleBase.start(
LifecycleBase.java:154
)
at org.apache.catalina.core.StandardService.startInternal(
StandardService.java:443
)
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:1131
)
at org.apache.catalina.core.StandardEngine.startInternal(
StandardEngine.java:300
)
at org.apache.catalina.util.LifecycleBase.start(
LifecycleBase.java:150
)
... 11 more
二、問題分析:
Document base H:\software\apache-tomcat\apache-tomcat-7.0.52\webapps\lemon does not exist or is not a
這句話告訴咱們在tomcat的webapps下找不到lemon這個項目 看了看 確實沒有.
此時,我能想到的就是work這個臨時文件夾,通常出錯都是這個臨時文件夾搞的鬼,可是delete掉後,問題依舊。
思來想去,想起了eclipse的workspace下的.metadata下的plugins內的插件org.eclipse.wst.server.core下有個配置文件servers.xml是指定部署項目的相關配置.
因而,我就想myeclipse通常是部署在真實的tomcat上,應該會修改 tomcat的配置文件,所以我找到了tomcat的配置文件server.xml
打開發現,
三、問題解決:
查了下context標籤的意思,原來,
<!-- tomcat配置的虛擬路徑 docBase="應用的實際目錄" 若是用myclipse編寫 則是webRoot Tomcat熱部署 -->
<!-- <Context docBase="lemon" path="/lemon" reloadable="true" source="org.eclipse.jst.j2ee.server:lemon"/> -->
最後,我分析多是由於咱們在用myeclipse開發時,因爲某種誤操做致使myeclipse沒有及時去更新server.xml配置文件,致使遺留了一些無效配置。
刪掉最後的那句<!-- <Context docBase="lemon" path="/lemon" reloadable="true" source="org.eclipse.jst.j2ee.server:lemon"/> -->,服務器正常啓動!