* Default domain for MBeans if none can be determined
*/
public static final String DEFAULT_MBEAN_DOMAIN = "Catalina";
+
+ /**
+ * Name of the system property containing
+ * the tomcat product installation path
+ */
+ public static final String CATALINA_HOME_PROP = "catalina.home";
+
+ /**
+ * Name of the system property containing
+ * the tomcat instance installation path
+ */
+ public static final String CATALINA_BASE_PROP = "catalina.base";
}
import javax.management.ObjectName;
+import org.apache.catalina.Globals;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleState;
import org.apache.catalina.Service;
protocolHandler.setAdapter(adapter);
IntrospectionUtils.setProperty(protocolHandler, "jkHome",
- System.getProperty("catalina.base"));
+ System.getProperty(Globals.CATALINA_BASE_PROP));
try {
protocolHandler.init();
* entire servlet container (i.e. the Engine container if present).
*/
protected File engineBase() {
- String base=System.getProperty("catalina.base");
+ String base=System.getProperty(Globals.CATALINA_BASE_PROP);
if( base == null ) {
StandardEngine eng=(StandardEngine)this.getParent().getParent();
base=eng.getBaseDir();
*/
public File getConfigBase() {
File configBase =
- new File(System.getProperty("catalina.base"), "conf");
+ new File(System.getProperty(Globals.CATALINA_BASE_PROP), "conf");
if (!configBase.exists()) {
return null;
}
import org.apache.catalina.Container;
import org.apache.catalina.Context;
import org.apache.catalina.Engine;
+import org.apache.catalina.Globals;
import org.apache.catalina.Host;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.ha.CatalinaCluster;
}
}
- configBase = new File(System.getProperty("catalina.base"), "conf");
+ configBase = new File(System.getProperty(Globals.CATALINA_BASE_PROP), "conf");
if (engine != null) {
configBase = new File(configBase, engine.getName());
}
File file = new File(host.getAppBase());
if (!file.isAbsolute())
- file = new File(System.getProperty("catalina.base"), host
+ file = new File(System.getProperty(Globals.CATALINA_BASE_PROP), host
.getAppBase());
try {
appBase = file.getCanonicalFile();
import org.apache.catalina.ContainerServlet;
import org.apache.catalina.Context;
import org.apache.catalina.Engine;
+import org.apache.catalina.Globals;
import org.apache.catalina.Host;
import org.apache.catalina.Manager;
import org.apache.catalina.Role;
String appBase = ((Host) context.getParent()).getAppBase();
deployed = new File(appBase);
if (!deployed.isAbsolute()) {
- deployed = new File(System.getProperty("catalina.base"),
+ deployed = new File(System.getProperty(Globals.CATALINA_BASE_PROP),
appBase);
}
- configBase = new File(System.getProperty("catalina.base"), "conf");
+ configBase = new File(System.getProperty(Globals.CATALINA_BASE_PROP), "conf");
Container container = context;
Container host = null;
Container engine = null;
File file = new File(host.getAppBase());
if (!file.isAbsolute())
- file = new File(System.getProperty("catalina.base"),
+ file = new File(System.getProperty(Globals.CATALINA_BASE_PROP),
host.getAppBase());
try {
appBase = file.getCanonicalFile();
import org.apache.catalina.ContainerServlet;
import org.apache.catalina.Context;
import org.apache.catalina.Engine;
+import org.apache.catalina.Globals;
import org.apache.catalina.Host;
import org.apache.catalina.Wrapper;
import org.apache.catalina.core.ContainerBase;
file = new File(appBase);
}
if (!file.isAbsolute())
- file = new File(System.getProperty("catalina.base"), file.getPath());
+ file = new File(System.getProperty(Globals.CATALINA_BASE_PROP), file.getPath());
try {
appBaseFile = file.getCanonicalFile();
} catch (IOException e) {
*/
protected File getConfigBase(String hostName) {
File configBase =
- new File(System.getProperty("catalina.base"), "conf");
+ new File(System.getProperty(Globals.CATALINA_BASE_PROP), "conf");
if (!configBase.exists()) {
return null;
}
import javax.security.auth.login.LoginException;
import javax.security.auth.spi.LoginModule;
+import org.apache.catalina.Globals;
import org.apache.catalina.authenticator.Constants;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
// Validate the existence of our configuration file
File file = new File(pathname);
if (!file.isAbsolute())
- file = new File(System.getProperty("catalina.base"), pathname);
+ file = new File(System.getProperty(Globals.CATALINA_BASE_PROP), pathname);
if (!file.exists() || !file.canRead()) {
log.warn("Cannot load configuration file " + file.getAbsolutePath());
return;
import java.util.HashMap;
import java.util.Map;
+import org.apache.catalina.Globals;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.util.LifecycleBase;
import org.apache.juli.logging.Log;
// Validate the existence of our database file
File file = new File(pathname);
if (!file.isAbsolute())
- file = new File(System.getProperty("catalina.base"), pathname);
+ file = new File(System.getProperty(Globals.CATALINA_BASE_PROP), pathname);
if (!file.exists() || !file.canRead())
throw new LifecycleException
(sm.getString("memoryRealm.loadExist",
import javax.management.MBeanServerFactory;
import javax.management.ObjectName;
+import org.apache.catalina.Globals;
import org.apache.catalina.security.SecurityClassLoad;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
// -------------------------------------------------------------- Constants
- protected static final String CATALINA_HOME_TOKEN = "${catalina.home}";
- protected static final String CATALINA_BASE_TOKEN = "${catalina.base}";
+ protected static final String CATALINA_HOME_TOKEN = "${" + Globals.CATALINA_HOME_PROP + "}";
+ protected static final String CATALINA_BASE_TOKEN = "${" + Globals.CATALINA_BASE_PROP + "}";
// ------------------------------------------------------- Static Variables
}
public void setCatalinaHome(String s) {
- System.setProperty( "catalina.home", s );
+ System.setProperty(Globals.CATALINA_HOME_PROP, s);
}
public void setCatalinaBase(String s) {
- System.setProperty( "catalina.base", s );
+ System.setProperty(Globals.CATALINA_BASE_PROP, s);
}
*/
private void setCatalinaBase() {
- if (System.getProperty("catalina.base") != null)
+ if (System.getProperty(Globals.CATALINA_BASE_PROP) != null)
return;
- if (System.getProperty("catalina.home") != null)
- System.setProperty("catalina.base",
- System.getProperty("catalina.home"));
+ if (System.getProperty(Globals.CATALINA_HOME_PROP) != null)
+ System.setProperty(Globals.CATALINA_BASE_PROP,
+ System.getProperty(Globals.CATALINA_HOME_PROP));
else
- System.setProperty("catalina.base",
+ System.setProperty(Globals.CATALINA_BASE_PROP,
System.getProperty("user.dir"));
}
*/
private void setCatalinaHome() {
- if (System.getProperty("catalina.home") != null)
+ if (System.getProperty(Globals.CATALINA_HOME_PROP) != null)
return;
File bootstrapJar =
new File(System.getProperty("user.dir"), "bootstrap.jar");
if (bootstrapJar.exists()) {
try {
System.setProperty
- ("catalina.home",
+ (Globals.CATALINA_HOME_PROP,
(new File(System.getProperty("user.dir"), ".."))
.getCanonicalPath());
} catch (Exception e) {
// Ignore
- System.setProperty("catalina.home",
+ System.setProperty(Globals.CATALINA_HOME_PROP,
System.getProperty("user.dir"));
}
} else {
- System.setProperty("catalina.home",
+ System.setProperty(Globals.CATALINA_HOME_PROP,
System.getProperty("user.dir"));
}
* Get the value of the catalina.home environment variable.
*/
public static String getCatalinaHome() {
- return System.getProperty("catalina.home",
+ return System.getProperty(Globals.CATALINA_HOME_PROP,
System.getProperty("user.dir"));
}
* Get the value of the catalina.base environment variable.
*/
public static String getCatalinaBase() {
- return System.getProperty("catalina.base", getCatalinaHome());
+ return System.getProperty(Globals.CATALINA_BASE_PROP, getCatalinaHome());
}
import java.util.logging.LogManager;
import org.apache.catalina.Container;
+import org.apache.catalina.Globals;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.Server;
import org.apache.catalina.core.StandardServer;
File file = new File(configFile);
if (!file.isAbsolute())
- file = new File(System.getProperty("catalina.base"), configFile);
+ file = new File(System.getProperty(Globals.CATALINA_BASE_PROP), configFile);
return (file);
}
protected void initDirs() {
- String catalinaHome = System.getProperty("catalina.home");
+ String catalinaHome = System.getProperty(Globals.CATALINA_HOME_PROP);
if (catalinaHome == null) {
// Backwards compatibility patch for J2EE RI 1.3
String j2eeHome = System.getProperty("com.sun.enterprise.home");
if (j2eeHome != null) {
catalinaHome=System.getProperty("com.sun.enterprise.home");
- } else if (System.getProperty("catalina.base") != null) {
- catalinaHome = System.getProperty("catalina.base");
+ } else if (System.getProperty(Globals.CATALINA_BASE_PROP) != null) {
+ catalinaHome = System.getProperty(Globals.CATALINA_BASE_PROP);
} else {
// Use IntrospectionUtils and guess the dir
catalinaHome = IntrospectionUtils.guessInstall
- ("catalina.home", "catalina.base", "catalina.jar");
+ (Globals.CATALINA_HOME_PROP, Globals.CATALINA_BASE_PROP, "catalina.jar");
if (catalinaHome == null) {
catalinaHome = IntrospectionUtils.guessInstall
- ("tomcat.install", "catalina.home", "tomcat.jar");
+ ("tomcat.install", Globals.CATALINA_HOME_PROP, "tomcat.jar");
}
}
}
catalinaHome = home.getAbsolutePath();
}
}
- System.setProperty("catalina.home", catalinaHome);
+ System.setProperty(Globals.CATALINA_HOME_PROP, catalinaHome);
}
- if (System.getProperty("catalina.base") == null) {
- System.setProperty("catalina.base",
+ if (System.getProperty(Globals.CATALINA_BASE_PROP) == null) {
+ System.setProperty(Globals.CATALINA_BASE_PROP,
catalinaHome);
} else {
- String catalinaBase = System.getProperty("catalina.base");
+ String catalinaBase = System.getProperty(Globals.CATALINA_BASE_PROP);
File base = new File(catalinaBase);
if (!base.isAbsolute()) {
try {
catalinaBase = base.getAbsolutePath();
}
}
- System.setProperty("catalina.base", catalinaBase);
+ System.setProperty(Globals.CATALINA_BASE_PROP, catalinaBase);
}
String temp = System.getProperty("java.io.tmpdir");
import java.util.Enumeration;
import java.util.Properties;
+import org.apache.catalina.Globals;
import org.apache.tomcat.util.ExceptionUtils;
InputStream is = null;
Throwable error = null;
+ ClassLoader cl = CatalinaProperties.class.getClassLoader();
+ System.err.println("CatalinaProprties: cl=" + cl.toString());
+ if ((cl = cl.getParent()) != null) {
+ System.err.println("CatalinaProprties: parent cl=" + cl.toString());
+ }
try {
String configUrl = getConfigUrl();
if (configUrl != null) {
* Get the value of the catalina.home environment variable.
*/
private static String getCatalinaHome() {
- return System.getProperty("catalina.home",
+ return System.getProperty(Globals.CATALINA_HOME_PROP,
System.getProperty("user.dir"));
}
* Get the value of the catalina.base environment variable.
*/
private static String getCatalinaBase() {
- return System.getProperty("catalina.base", getCatalinaHome());
+ return System.getProperty(Globals.CATALINA_BASE_PROP, getCatalinaHome());
}
import org.apache.catalina.Container;
import org.apache.catalina.Context;
import org.apache.catalina.Engine;
+import org.apache.catalina.Globals;
import org.apache.catalina.Host;
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleException;
return await;
}
- public void setCatalinaHome( String s ) {
- System.setProperty( "catalina.home", s);
+ public void setCatalinaHome(String s) {
+ System.setProperty(Globals.CATALINA_HOME_PROP, s);
}
- public void setCatalinaBase( String s ) {
- System.setProperty( "catalina.base", s);
+ public void setCatalinaBase(String s) {
+ System.setProperty(Globals.CATALINA_BASE_PROP, s);
}
public String getCatalinaHome() {
- return System.getProperty("catalina.home");
+ return System.getProperty(Globals.CATALINA_HOME_PROP);
}
public String getCatalinaBase() {
- return System.getProperty("catalina.base");
+ return System.getProperty(Globals.CATALINA_BASE_PROP);
}
protected void initDirs() {
- String catalinaHome = System.getProperty("catalina.home");
+ String catalinaHome = System.getProperty(Globals.CATALINA_HOME_PROP);
if (catalinaHome == null) {
// Backwards compatibility patch for J2EE RI 1.3
String j2eeHome = System.getProperty("com.sun.enterprise.home");
if (j2eeHome != null) {
catalinaHome=System.getProperty("com.sun.enterprise.home");
- } else if (System.getProperty("catalina.base") != null) {
- catalinaHome = System.getProperty("catalina.base");
+ } else if (System.getProperty(Globals.CATALINA_BASE_PROP) != null) {
+ catalinaHome = System.getProperty(Globals.CATALINA_BASE_PROP);
} else {
// Use IntrospectionUtils and guess the dir
catalinaHome = IntrospectionUtils.guessInstall
- ("catalina.home", "catalina.base", "catalina.jar");
+ (Globals.CATALINA_HOME_PROP, Globals.CATALINA_BASE_PROP, "catalina.jar");
if (catalinaHome == null) {
catalinaHome = IntrospectionUtils.guessInstall
- ("tomcat.install", "catalina.home", "tomcat.jar");
+ ("tomcat.install", Globals.CATALINA_HOME_PROP, "tomcat.jar");
}
}
}
catalinaHome = home.getAbsolutePath();
}
}
- System.setProperty("catalina.home", catalinaHome);
+ System.setProperty(Globals.CATALINA_HOME_PROP, catalinaHome);
}
- if (System.getProperty("catalina.base") == null) {
- System.setProperty("catalina.base",
+ if (System.getProperty(Globals.CATALINA_BASE_PROP) == null) {
+ System.setProperty(Globals.CATALINA_BASE_PROP,
catalinaHome);
} else {
- String catalinaBase = System.getProperty("catalina.base");
+ String catalinaBase = System.getProperty(Globals.CATALINA_BASE_PROP);
File base = new File(catalinaBase);
if (!base.isAbsolute()) {
try {
catalinaBase = base.getAbsolutePath();
}
}
- System.setProperty("catalina.base", catalinaBase);
+ System.setProperty(Globals.CATALINA_BASE_PROP, catalinaBase);
}
String temp = System.getProperty("java.io.tmpdir");
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
+import org.apache.catalina.Globals;
import org.apache.catalina.Host;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
// Make sure that there is no such directory already existing
File appBase = new File(host.getAppBase());
if (!appBase.isAbsolute()) {
- appBase = new File(System.getProperty("catalina.base"),
+ appBase = new File(System.getProperty(Globals.CATALINA_BASE_PROP),
host.getAppBase());
}
if (!appBase.exists() || !appBase.isDirectory()) {
// Make the appBase absolute
File appBase = new File(host.getAppBase());
if (!appBase.isAbsolute()) {
- appBase = new File(System.getProperty("catalina.base"),
+ appBase = new File(System.getProperty(Globals.CATALINA_BASE_PROP),
host.getAppBase());
}
import org.apache.catalina.Container;
import org.apache.catalina.Context;
import org.apache.catalina.Engine;
+import org.apache.catalina.Globals;
import org.apache.catalina.Host;
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleEvent;
protected File returnCanonicalPath(String path) {
File file = new File(path);
- File base = new File(System.getProperty("catalina.base"));
+ File base = new File(System.getProperty(Globals.CATALINA_BASE_PROP));
if (!file.isAbsolute())
file = new File(base,path);
try {
import org.apache.catalina.Container;
import org.apache.catalina.Context;
import org.apache.catalina.Engine;
+import org.apache.catalina.Globals;
import org.apache.catalina.Host;
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleEvent;
protected void initBaseDir() {
if (basedir == null) {
- basedir = System.getProperty("catalina.base");
+ basedir = System.getProperty(Globals.CATALINA_BASE_PROP);
}
if (basedir == null) {
- basedir = System.getProperty("catalina.home");
+ basedir = System.getProperty(Globals.CATALINA_HOME_PROP);
}
if (basedir == null) {
// Create a temp dir.
}
}
}
- System.setProperty("catalina.home", basedir);
- System.setProperty("catalina.base", basedir);
+ System.setProperty(Globals.CATALINA_HOME_PROP, basedir);
+ System.setProperty(Globals.CATALINA_BASE_PROP, basedir);
}
static String[] silences = new String[] {
import java.lang.reflect.Method;
import java.util.ArrayList;
+import org.apache.catalina.Globals;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
/**
* The pathname of our installation base directory.
*/
- private static String catalinaHome = System.getProperty("catalina.home");
+ private static String catalinaHome = System.getProperty(Globals.CATALINA_HOME_PROP);
/**
// Verify that "catalina.home" was passed.
if (catalinaHome == null) {
- log.error("Must set 'catalina.home' system property");
+ log.error("Must set '" + Globals.CATALINA_HOME_PROP + "' system property");
System.exit(1);
}
import java.util.HashMap;
import java.util.Iterator;
+import org.apache.catalina.Globals;
import org.apache.catalina.Group;
import org.apache.catalina.Role;
import org.apache.catalina.User;
// Construct a reader for the XML input file (if it exists)
File file = new File(pathname);
if (!file.isAbsolute()) {
- file = new File(System.getProperty("catalina.base"),
+ file = new File(System.getProperty(Globals.CATALINA_BASE_PROP),
pathname);
}
if (!file.exists()) {
File file = new File(pathname);
if (!file.isAbsolute()) {
- file = new File(System.getProperty("catalina.base"),
+ file = new File(System.getProperty(Globals.CATALINA_BASE_PROP),
pathname);
}
File dir = file.getParentFile();
File fileNew = new File(pathnameNew);
if (!fileNew.isAbsolute()) {
fileNew =
- new File(System.getProperty("catalina.base"), pathnameNew);
+ new File(System.getProperty(Globals.CATALINA_BASE_PROP), pathnameNew);
}
PrintWriter writer = null;
try {
File fileOld = new File(pathnameOld);
if (!fileOld.isAbsolute()) {
fileOld =
- new File(System.getProperty("catalina.base"), pathnameOld);
+ new File(System.getProperty(Globals.CATALINA_BASE_PROP), pathnameOld);
}
fileOld.delete();
File fileOrig = new File(pathname);
if (!fileOrig.isAbsolute()) {
fileOrig =
- new File(System.getProperty("catalina.base"), pathname);
+ new File(System.getProperty(Globals.CATALINA_BASE_PROP), pathname);
}
if (fileOrig.exists()) {
fileOld.delete();
import javax.servlet.http.HttpSession;
import org.apache.catalina.AccessLog;
+import org.apache.catalina.Globals;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleState;
import org.apache.catalina.connector.Request;
// Create the directory if necessary
File dir = new File(directory);
if (!dir.isAbsolute())
- dir = new File(System.getProperty("catalina.base"), directory);
+ dir = new File(System.getProperty(Globals.CATALINA_BASE_PROP), directory);
dir.mkdirs();
// Open the current log file
import java.io.PrintStream;
import java.util.StringTokenizer;
+import org.apache.catalina.Globals;
import org.apache.jasper.JasperException;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
logger.setErrorPrintStream(System.err);
logger.setMessageOutputLevel(Project.MSG_INFO);
project.addBuildListener( logger);
- if (System.getProperty("catalina.home") != null) {
- project.setBasedir( System.getProperty("catalina.home"));
+ if (System.getProperty(Globals.CATALINA_HOME_PROP) != null) {
+ project.setBasedir(System.getProperty(Globals.CATALINA_HOME_PROP));
}
if( options.getCompiler() != null ) {
import javax.net.ssl.KeyManagerFactory;
+import org.apache.catalina.Globals;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
import org.apache.tomcat.util.IntrospectionUtils;
private String keystoreFile = System.getProperty("user.home")+"/.keystore";
public String getKeystoreFile() { return keystoreFile;}
public void setKeystoreFile(String s ) {
- String file = adjustRelativePath(s,System.getProperty("catalina.base"));
+ String file = adjustRelativePath(s, System.getProperty(Globals.CATALINA_BASE_PROP));
this.keystoreFile = file;
}
private String truststoreFile = System.getProperty("javax.net.ssl.trustStore");
public String getTruststoreFile() {return truststoreFile;}
public void setTruststoreFile(String s) {
- String file = adjustRelativePath(s,System.getProperty("catalina.base"));
+ String file = adjustRelativePath(s, System.getProperty(Globals.CATALINA_BASE_PROP));
this.truststoreFile = file;
}
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509KeyManager;
+import org.apache.catalina.Globals;
import org.apache.tomcat.util.net.AbstractEndpoint;
import org.apache.tomcat.util.res.StringManager;
"".equalsIgnoreCase(path))) {
File keyStoreFile = new File(path);
if (!keyStoreFile.isAbsolute()) {
- keyStoreFile = new File(System.getProperty("catalina.base"),
+ keyStoreFile = new File(System.getProperty(Globals.CATALINA_BASE_PROP),
path);
}
istream = new FileInputStream(keyStoreFile);
File crlFile = new File(crlf);
if( !crlFile.isAbsolute() ) {
- crlFile = new File(System.getProperty("catalina.base"), crlf);
+ crlFile = new File(System.getProperty(Globals.CATALINA_BASE_PROP), crlf);
}
Collection<? extends CRL> crls = null;
InputStream is = null;
is being destroyed, the destroy method is only called once on each
child component. (markt)
</update>
+ <update>
+ <bug>48967</bug>: Replace strings "catalina.base" and "catalina.home"
+ by globally defined constants. Patch provided by Marc Guillemot. (rjung)
+ </update>
</changelog>
</subsection>
<subsection name="Coyote">