user1649415
user1649415

Reputation: 1095

CATALINA_HOME path set up

During installation of Tomcat, multiple forums have that CATALINA_HOME variable needs to be set up and shall point to Tomcat parent directory. I am running web projects through eclipse and it runs in presence and also in absence of this environment variable set up.

I wish to know what exact purpose does this variable solve and when does setting it up become mandatory.

Also I wish to know the exact use of tomcat-juli.jar that resides in the Tomcat/bin directory

Upvotes: 1

Views: 8633

Answers (2)

navyad
navyad

Reputation: 3860

once you installed the Tomcat check the tomcat properties under java options following variables has been set by default.

-Dcatalina.home=C:\Program Files (x86)\Apache Software Foundation\Tomcat 6.0 

-Dcatalina.base=C:\Program Files (x86)\Apache Software Foundation\Tomcat 6.0 

-Djava.endorsed.dirs=C:\Program Files (x86)\Apache Software Foundation\Tomcat 6.0\endorsed 

-Djava.io.tmpdir=C:\Program Files (x86)\Apache Software Foundation\Tomcat 6.0\temp 

-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager 

-Djava.util.logging.config.file=C:\Program Files (x86)\Apache SoftwareFoundation\Tomcat 
6.0\conf\logging.properties 

You do not need to set CATALINA_HOME yourself , even when runing inside Eclipse. The only times you HAVE to set CATALINA_HOME and/or CATALINA_BASE are if you want to override the default values. Most commonly, you'd do that if you were using the same Tomcat binaries to run multiple instances of Tomcat.

tomcat-juli.jar

This tomcat-juli.jar is a third party component used for logging purposes. It contains the full Apache Commons Logging implementation and thus is able to discover the presense of log4j and configure itself.

how you can use tomcat-juli.jar

If you want to configure Tomcat to use log4j globally:

  1. Download or build tomcat-juli.jar and tomcat-juli-adapters.jar that are available as an "extras" component for Tomcat.
  2. Put log4j.jar and tomcat-juli-adapters.jar from "extras" into $CATALINA_HOME/lib. Replace $CATALINA_HOME/bin/tomcat-juli.jar with tomcat-juli.jar from "extras".

Upvotes: 1

mindas
mindas

Reputation: 26713

Q> what exact purpose does this variable solve
A> Javadoc of the Bootstrap class says:

This application constructs a class loader for use in loading the Catalina internal classes (by accumulating all of the JAR files found in the "server" directory under "catalina.home"), and starts the regular execution of the container. The purpose of this roundabout approach is to keep the Catalina internal classes (and any other classes they depend on, such as an XML parser) out of the system class path and therefore not visible to application level classes.

But there's more. CATALINA_HOME and (interchangeably) CATALINA_BASE define a "base directory", which is used to reference the work directory (which is used to keep compiled jsps), also helps to find context configuration files and so on.

It could be that Eclipse sets these properties without your knowledge. Print all system properties to see what's in.

Q> when does setting it up become mandatory
A> from as far as I can remember

Q> the exact use of tomcat-juli.jar
A> Straight from Tomcat documentation:

Apache Tomcat has its own implementation of several key elements of java.util.logging API. This implementation is called "JULI". The key component there is a custom LogManager implementation, that is aware of different web applications running on Tomcat (and their different class loaders). It supports private per-application logging configurations. It is also notified by Tomcat when a web application is unloaded from memory, so that the references to its classes can be cleared, preventing memory leaks.

Upvotes: 1

Related Questions