I wrote a special Tomcat valve. (I am using Tomcat 6.0.24 and Java 1.6) Here is the XML element where I declare my valve:
<Valve className="mypkg.MyValve" foo="bar"/>
When I put this ad in the Host.xml element of Host.xml. Tomcat calls the setFoo () method on my valve with a value of "bar". This is what I want.
However, when I put the same declaration in my webapp META-INF / context.xml, inside the Context element, Tomcat loads the valve and the valve works fine. But Tomcat never calls the setFoo () method to provide the "bar" value that the valve requires.
I donβt understand why Tomcat correctly configures the valve specified in server.xml, but not in the .xml context.
Does anyone know how I can get Tomcat to properly configure my valve when it is declared in my webapp META-INF / context.xml?
Thanks Dan
This causes my valve to load and configure Tomcat correctly:
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <Valve className="mypkg.MyValve" foo="bar"/> </Host>
This causes my valve to load, but Tomcat will not give it the configuration parameter "bar":
<Context privileged="true" > <Valve className="mypkg.MyValve" foo="bar"/> </Context>
source share