I am trying to override a parameter in my application’s web.xml file by creating a context.xml file in <tomcatHome>/conf/Catalina/localhost
The context.xml file looks like
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/myapp">
<Parameter name="port" value="100" override="1"/>
</Context>
but I get an error saying
java.lang.IllegalArgumentException: Document base <path-to-tomcat> apache-tomcat-7.0.35/webapps/context does not exist or is not a readable directory
If I put the <Parameter name="port" value="100" override="1"/> directly in the context.xml in <tomcat-home>/context.xml then it works.
Can someon explain what I am doing incorrectly?
It is because there is no such application context with the name context. In other words there is no web app with the name context deployed to the webapps directory.
Form the official Tomcat 7 documentation related to Defining a context:
So to make it work, name your custom file not context.xml, but your_app_name.xml.
In your case it will be (if I understood you correctly) myapp.xml.
This should work. I have just tested it.
myapp.xml
P.S.
And you can get without path attribute, so don’t include it.
From the Apache Tomcat 7 documentation: