Shared configuration on Tomcat 6

In Tomcat 5 there was the famous ${catalina.home}/shared/classes which you could use for sharing class files, properties files etc. Tomcat 6 by default doesn't come with this directory. In a first glance it seems that you can't do it anymore :-(.. But that's not true :-)..

You need to configure Tomcat to point to a directory which you want to be shared location so applications can pick up resources from the classpath. The configuration is very simple. Just go to ${catalina.home}/conf and open catalina.properties. Add the path to the shared.loader property. It will look something like this:
#
# List of comma-separated paths defining the contents of the "shared" 
# classloader. 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 
# Please note that for single jars, e.g. bar.jar, you need the URL form
# starting with file:.
shared.loader=${catalina.home}/shared/classes

This can be very usefull when you want to share configuration between several web applications or even just to decouple the configuration from your web application in an easy way. Using this makes it easier to have a platform independent configuration without creating separate artifacts for every platform. :-)

Comments

Popular posts from this blog

Fastest XML parser

Tomcat behind Apache HTTP server using Spring Security

Cargo-itest open source project