Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

excerptINLINE

In Tomcat, a valve is a Java class that can be inserted into the request processing pipeline. A valve executes as part of Tomcat's servlet container and is independent of the Web application.

...

Currently, the valve cannot be configured by using the administration console. Tomcat valves are initially defined in the <geronimo_home>/repository/org/apache/geronimo/configs/tomcat6/2.2/tomcat6-2.2.car/META-INF/plan.xml file. To change valves configuration, you must modify <Geronimo_home>/var/config/config.xml.

The following sections illustrate common changes that you might want to make to your valve chain.

...

...

Disable the Access Log Valve

...

  1. Stop the server.
  2. Backup the <geronimo_home>/var/config/config.xml file and then open it in an editor.
  3. Add the following code right after the <module name="org.apache.geronimo.configs/tomcat6/2.2/car"> tag to disable the Access Log Valve, and then restart the server after you save the file. Code Block <module name="org.apache.geronimo.configs/tomcat6/2.2/car"> ... <gbean name="TomcatEngine"> <attribute name="initParams"> name=Geronimo </attribute> <reference name="TomcatValveChain"/> </gbean> <gbean name="AccessLogValve" load="false"></gbean> ...

Add a second Valve

This section takes the Single Sign-on Valve as an example. The Single Sign-on Valve is used to give users the ability to sign on to any Web application and then have their identity recognized by all other Web applications within the same container. To add the Single Sign-on Valve to the Access Log Valve in the initial valve chain, use the following procedure:

  1. Stop the server.
  2. Backup <geronimo_home>/var/config/config.xml file and then open it in an editor.
  3. Add the following code right after the <module name="org.apache.geronimo.configs/tomcat6/2.2/car"> tag to define the Single Sign-on Valve, and then restart the server after you save the file. Code Block <module name="org.apache.geronimo.configs/tomcat6/2.2/car"> <gbean name="AccessLogValve"> <reference name="NextValve"> <pattern> <name>SSOValve</name> </pattern> </reference> </gbean> <gbean gbeanInfo="org.apache.geronimo.tomcat.ValveGBean" name="org.apache.geronimo.configs/tomcat6/2.2/car?ServiceModule=org.apache.geronimo.configs/tomcat6/2.2/car, j2eeType=GBean,name=SSOValve"> <attribute name="className">org.apache.catalina.authenticator.SingleSignOn</attribute> </gbean>
    • The j2eeType= attribute in the added <gbean> tags have been split across several lines for readability. In your file, the attribute must be on a single line. Also, you can add the other Valves by replacing org.apache.catalina.authenticator.SingleSignOn in the <attribute name="className"> </attribute> block.

...

  1. Stop the server.
  2. Backup <geronimo_home>/var/config/config.xml file and then open it in an editor.
  3. Add the following code right after the <module name="org.apache.geronimo.configs/tomcat6/2.2/car"> tag to define a valve chain, and then restart the server after you save the file. Code Block <module name="org.apache.geronimo.configs/tomcat6/2.2/car"> <gbean name="TomcatHost"> ... <reference name="TomcatValveChain"> <pattern> <name>valve0</name> </pattern> </reference> </gbean> <gbean gbeanInfo="org.apache.geronimo.tomcat.ValveGBean" name="org.apache.geronimo.configs/tomcat6/2.2/car?ServiceModule=org.apache.geronimo.configs/tomcat6/2.2/car, j2eeType=GBean,name=valve0"> <attribute name="className">class</attribute> <attribute name="initParams">parms</attribute> <reference name="TomcatValveChain"> <pattern> <name>valve1</name> </pattern> </reference> </gbean> <gbean gbeanInfo="org.apache.geronimo.tomcat.ValveGBean" name="org.apache.geronimo.configs/tomcat6/2.2/car?ServiceModule=org.apache.geronimo.configs/tomcat6/2.2/car, j2eeType=GBean,name=valve1"> <attribute name="className">class</attribute> <attribute name="initParams">parms</attribute> <reference name="TomcatValveChain"> <pattern> <name>valve2</name> </pattern> </reference> </gbean> ... <gbean gbeanInfo="org.apache.geronimo.tomcat.ValveGBean" name="org.apache.geronimo.configs/tomcat6/2.2/car?ServiceModule=org.apache.geronimo.configs/tomcat6/2.2/car, j2eeType=GBean,name=valvex"> <attribute name="className">class</attribute> <attribute name="initParams">parms</attribute> </gbean> where
  • TomcatHost is the name of the Tomcat virtual host GBean that is to be customized.
  • valve0 is the system unique name for the first valve GBean in the chain.
  • valve1 is the system unique name for the second valve GBean in the chain.
  • valvex is the system unique name for the last valve GBean in the chain.
  • class is the class name of a valid Tomcat valve.
  • parms is a white space separated list of valve parameters. In this list, each valve parameter has the form key=value where key is the keyword for the parameter and value is the value of the parameter. See the valve's documentation for information about supported parameters, if any.