问题
I am deploying my project to AWS with Apache Tomcat 7. I added the ROOT.xml
into Catalina/localhost/
like this
<Context
path="/"
docBase="/home/ec2-user/myproject/web"
workDir="/home/ec2-user/myproject/work"
crossContext="true">
</Context>
Starting Tomcat gives me the famous exception of Tomcat, but sadly, I cannot resolve it
java.lang.IllegalArgumentException: Document base /home/ec2-user/myproject/web 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:5247)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5436)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:679)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1966)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:473)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:622)
at java.lang.Thread.run(Thread.java:748)
Things I tried:
sudo chown -R tomcat:tomcat web && sudo chmod 775 -R web
(Does not work)sudo ln -s web /etc/tomcat/web
(Does not work)sudo cp -rf web /etc/tomcat/web
(Work, actually, if I move theweb
folder anywhere outside of/home/ec2-user
, it starts to work)
How can I make this work with the web
folder under the ec2-user
?
回答1:
Problem solved. Edit /etc/tomcat7/tomcat7.conf
from
TOMCAT_USER="tomcat"
to
TOMCAT_USER="root"
Not the best way, but I can continue my work now
来源:https://stackoverflow.com/questions/48235060/document-base-home-ec2-user-myproject-web-does-not-exist-or-is-not-a-readable-d