Using catalina.properties to Configure Tomcats Class Loaders

Using catalina.properties to Configure Tomcat’s Class Loaders

You use the catalina.properties file to configure Tomcat’s class loaders. These determine which classes are available to different parts of the server. In the previous chapter, you saw the three directories, common, server, and shared, that are set as the path for the class loaders by default. You can change these directories in catalina.properties.

Another setting you can alter here is the classes that are available to Web applications running on the server. When a class loader tries to load a forbidden class, a java.security.AccessControlException is thrown. This setting applies only if you start Tomcat in security mode.

The first section lists the forbidden packages. By default, Tomcat won’t allow Web applications to load any of Tomcat’s internal classes.

 # List of comma-separated packages that start with or equal this string  # will cause a security exception to be thrown when  # passed to checkPackageAccess unless the  # corresponding RuntimePermission ("accessClassInPackage."+package) has  # been granted.  package.access=sun.,org.apache.catalina.,org.apache.coyote.,  org.apache.tomcat.,org.apache.jasper.,sun.beans. 

If a Web application on your server wants to have access to an internal class, say org.apache.tomcat.util.IntrospectionUtils, and you’re happy about letting it, then you would add the following to catalina.policy:

     // Permission for org.apache.tomcat. package      permission java.lang.RuntimePermission        "accessClassInPackage.org.apache.tomcat.util"; 

The next section disallows users from defining classes in certain restricted packages.

 # List of comma-separated packages that start with or equal this string  # will cause a security exception to be thrown when  # passed to checkPackageDefinition unless the  # corresponding RuntimePermission ("defineClassInPackage."+package) has  # been granted.  #  # by default, no packages are restricted for definition, and none of  # the class loaders supplied with the JDK call checkPackageDefinition.  #  package.definition=sun.,java.,org.apache.catalina.,org.apache.coyote.,    org.apache.tomcat.,org.apache.jasper. 

This section is here for completeness only and doesn’t affect Tomcat’s operation.

The next section defines Tomcat’s common class loader, which in this case corresponds to the common directory and its subdirectories.

 # List of comma-separated paths defining the contents of the "common"  # class loader. Prefixes should be used to define what is the repository type.  # Path may be relative to the CATALINA_HOME path or absolute. If left as blank,  # the JVM system loader will be used as Catalina's "common" loader.  # Examples:  #     "foo": Add this folder as a class repository  #     "foo/*.jar": Add all the JARs of the specified folder as class  #                  repositories  #     "foo/bar.jar": Add bar.jar as a class repository  common.loader=${catalina.home}/common/classes,${catalina.home}    /common/endorsed/*.jar,${catalina.home}/common/lib/*.jar 

Tomcat 5.5 has a slightly different setting to account for its different directory structure.

 # Tomcat 5.5  common.loader=${catalina.home}/common/classes,    ${catalina.home}/common/i18n/*.jar,    ${catalina.home}/common/endorsed/*.jar,    ${catalina.home}/common/lib/*.jar 

Any classes placed in these directories will be available to Tomcat’s internal classes as well as all Web applications.

The next section defines Tomcat’s server class loader, which in this case corresponds to the server directory and its subdirectories.

 # List of comma-separated paths defining the contents of the "server"  # class loader. Prefixes should be used to define what is the repository type.  # Path may be relative to the CATALINA_HOME path or absolute. If left as blank,  # the "common" loader will be used as Catalina's "server" loader.  # Examples:  #     "foo": Add this folder as a class repository  #     "foo/*.jar": Add all the JARs of the specified folder as class  #                  repositories  #     "foo/bar.jar": Add bar.jar as a class repository  server.loader=${catalina.home}/server/classes,${catalina.home}/server/lib/*.jar 

Any classes placed in these directories will be available to Tomcat’s internal classes only.

The final section of this file defines Tomcat’s shared class loader, which in this case corresponds to the shared directory and its subdirectories. If this definition is left out, the common class loader will be used.

 # List of comma-separated paths defining the contents of the "shared"  # class loader. Prefixes should be used to define what is the repository type.  # Path may be relative to the CATALINA_BASE path or absolute. If left as blank,  # the "common" loader will be used as Catalina's "shared" loader.  # Examples:  #     "foo": Add this folder as a class repository  #     "foo/*.jar": Add all the JARs of the specified folder as class  #                  repositories  #     "foo/bar.jar": Add bar.jar as a class repository  shared.loader=${catalina.base}/shared/classes,${catalina.base}/shared/lib/*.jar 

Any classes placed in these directories will be available to Web applications but not Tomcat’s internal classes.



Pro Jakarta Tomcat 5
Pro Apache Tomcat 5/5.5 (Experts Voice in Java)
ISBN: 1590593316
EAN: 2147483647
Year: 2004
Pages: 94

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net