fi
fi
+elif [ "$1" = "configtest" ] ; then
+
+ eval \"$_RUNJAVA\" $JAVA_OPTS $CATALINA_OPTS \
+ -Djava.endorsed.dirs=\"$JAVA_ENDORSED_DIRS\" -classpath \"$CLASSPATH\" \
+ -Dcatalina.base=\"$CATALINA_BASE\" \
+ -Dcatalina.home=\"$CATALINA_HOME\" \
+ -Djava.io.tmpdir=\"$CATALINA_TMPDIR\" \
+ org.apache.catalina.startup.Bootstrap configtest
+ exit $?
+
elif [ "$1" = "version" ] ; then
"$_RUNJAVA" \
--- /dev/null
+#!/bin/sh
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# -----------------------------------------------------------------------------
+# configtest for the CATALINA Server
+#
+# $Id: configtest.sh $
+# -----------------------------------------------------------------------------
+
+# Better OS/400 detection: see Bugzilla 31132
+os400=false
+darwin=false
+case "`uname`" in
+CYGWIN*) cygwin=true;;
+OS400*) os400=true;;
+Darwin*) darwin=true;;
+esac
+
+# resolve links - $0 may be a softlink
+PRG="$0"
+
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`/"$link"
+ fi
+done
+
+PRGDIR=`dirname "$PRG"`
+EXECUTABLE=catalina.sh
+
+# Check that target executable exists
+if $os400; then
+ # -x will Only work on the os400 if the files are:
+ # 1. owned by the user
+ # 2. owned by the PRIMARY group of the user
+ # this will not work if the user belongs in secondary groups
+ eval
+else
+ if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then
+ echo "Cannot find $PRGDIR/$EXECUTABLE"
+ echo "This file is needed to run this program"
+ exit 1
+ fi
+fi
+
+exec "$PRGDIR"/"$EXECUTABLE" configtest "$@"
+
tarfile="${tomcat.release}/v${version}/bin/${final.name}.tar.gz">
<tarfileset dir="${tomcat.dist}" mode="755" prefix="${final.name}">
<include name="bin/catalina.sh" />
+ <include name="bin/configtest.sh" />
<include name="bin/digest.sh" />
<include name="bin/jasper.sh" />
<include name="bin/jspc.sh" />
<include name="RUNNING.txt" />
<include name="BENCHMARKS.txt" />
<exclude name="bin/catalina.sh" />
+ <exclude name="bin/configtest.sh" />
<exclude name="bin/digest.sh" />
<exclude name="bin/jasper.sh" />
<exclude name="bin/jspc.sh" />
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
public final class Bootstrap {
private static final Log log = LogFactory.getLog(Bootstrap.class);
-
+
// -------------------------------------------------------------- Constants
ArrayList<String> repositoryLocations = new ArrayList<String>();
ArrayList<Integer> repositoryTypes = new ArrayList<Integer>();
int i;
-
+
StringTokenizer tokenizer = new StringTokenizer(value, ",");
while (tokenizer.hasMoreElements()) {
String repository = tokenizer.nextToken();
while ((i=repository.indexOf(CATALINA_HOME_TOKEN))>=0) {
replace=true;
if (i>0) {
- repository = repository.substring(0,i) + getCatalinaHome()
+ repository = repository.substring(0,i) + getCatalinaHome()
+ repository.substring(i+CATALINA_HOME_TOKEN.length());
} else {
- repository = getCatalinaHome()
+ repository = getCatalinaHome()
+ repository.substring(CATALINA_HOME_TOKEN.length());
}
}
while ((i=repository.indexOf(CATALINA_BASE_TOKEN))>=0) {
replace=true;
if (i>0) {
- repository = repository.substring(0,i) + getCatalinaBase()
+ repository = repository.substring(0,i) + getCatalinaBase()
+ repository.substring(i+CATALINA_BASE_TOKEN.length());
} else {
- repository = getCatalinaBase()
+ repository = getCatalinaBase()
+ repository.substring(CATALINA_BASE_TOKEN.length());
}
}
String[] locations = repositoryLocations.toArray(new String[0]);
Integer[] types = repositoryTypes.toArray(new Integer[0]);
-
+
ClassLoader classLoader = ClassLoaderFactory.createClassLoader
(locations, types, parent);
param = new Object[1];
param[0] = arguments;
}
- Method method =
+ Method method =
catalinaDaemon.getClass().getMethod(methodName, paramTypes);
if (log.isDebugEnabled())
log.debug("Calling startup class " + method);
}
+ /**
+ * getServer() for configtest
+ */
+ private Object getServer() throws Exception {
+
+ String methodName = "getServer";
+ Method method =
+ catalinaDaemon.getClass().getMethod(methodName);
+ return method.invoke(catalinaDaemon);
+
+ }
+
+
// ----------------------------------------------------------- Main Program
public void stopServer()
throws Exception {
- Method method =
+ Method method =
catalinaDaemon.getClass().getMethod("stopServer", (Class []) null);
method.invoke(catalinaDaemon, (Object []) null);
param = new Object[1];
param[0] = arguments;
}
- Method method =
+ Method method =
catalinaDaemon.getClass().getMethod("stopServer", paramTypes);
method.invoke(catalinaDaemon, param);
paramTypes[0] = Boolean.TYPE;
Object paramValues[] = new Object[1];
paramValues[0] = Boolean.valueOf(await);
- Method method =
+ Method method =
catalinaDaemon.getClass().getMethod("setAwait", paramTypes);
method.invoke(catalinaDaemon, paramValues);
daemon.start();
} else if (command.equals("stop")) {
daemon.stopServer(args);
+ } else if (command.equals("configtest")) {
+ daemon.load(args);
+ if (null==daemon.getServer()) {
+ System.exit(1);
+ }
+ System.exit(0);
} else {
log.warn("Bootstrap: command \"" + command + "\" does not exist.");
}
} catch (Throwable t) {
handleThrowable(t);
t.printStackTrace();
+ System.exit(1);
}
}
if (System.getProperty(Globals.CATALINA_HOME_PROP) != null)
return;
- File bootstrapJar =
+ File bootstrapJar =
new File(System.getProperty("user.dir"), "bootstrap.jar");
if (bootstrapJar.exists()) {
try {
System.setProperty
- (Globals.CATALINA_HOME_PROP,
+ (Globals.CATALINA_HOME_PROP,
(new File(System.getProperty("user.dir"), ".."))
.getCanonicalPath());
} catch (Exception e) {
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* "catalina.base" system property. [conf/server.xml]
* <li><b>-help</b> - Display usage information.
* <li><b>-nonaming</b> - Disable naming support.
+ * <li><b>configtest</b> - Try to test the config
* <li><b>start</b> - Start an instance of Catalina.
* <li><b>stop</b> - Stop the currently running instance of Catalina.
* </u>
*/
protected Server server = null;
-
+
/**
* Are we starting a new server?
*/
// ----------------------------------------------------------- Constructors
-
+
public Catalina() {
setSecurityProtection();
}
-
-
+
+
// ------------------------------------------------------------- Properties
} else if (args[i].equals("start")) {
starting = true;
stopping = false;
+ } else if (args[i].equals("configtest")) {
+ starting = true;
+ stopping = false;
} else if (args[i].equals("stop")) {
starting = false;
stopping = true;
"addExecutor",
"org.apache.catalina.Executor");
-
+
digester.addRule("Server/Service/Connector",
new ConnectorCreateRule());
- digester.addRule("Server/Service/Connector",
+ digester.addRule("Server/Service/Connector",
new SetAllPropertiesRule(new String[]{"executor"}));
digester.addSetNext("Server/Service/Connector",
"addConnector",
// Stop the existing server
try {
- if (getServer().getPort()>0) {
+ if (getServer().getPort()>0) {
Socket socket = new Socket(getServer().getAddress(),
getServer().getPort());
OutputStream stream = socket.getOutputStream();
// Ignore
}
}
-
+
if ((inputStream == null) && (file != null)) {
log.warn("Can't load server.xml from " + file.getAbsolutePath());
} catch (LifecycleException e) {
if (Boolean.getBoolean("org.apache.catalina.startup.EXIT_ON_INIT_FAILURE"))
throw new java.lang.Error(e);
- else
+ else
log.error("Catalina.start", e);
-
+
}
long t2 = System.nanoTime();
}
- /*
+ /*
* Load using arguments
*/
public void load(String args[]) {
shutdownHook = new CatalinaShutdownHook();
}
Runtime.getRuntime().addShutdownHook(shutdownHook);
-
+
// If JULI is being used, disable JULI's shutdown hook since
// shutdown hooks run in parallel and log messages may be lost
// if JULI's hook completes before the CatalinaShutdownHook()
public void stop() {
try {
- // Remove the ShutdownHook first so that server.stop()
+ // Remove the ShutdownHook first so that server.stop()
// doesn't get invoked twice
if (useShutdownHook) {
Runtime.getRuntime().removeShutdownHook(shutdownHook);
}
}
}
- // last resort - for minimal/embedded cases.
+ // last resort - for minimal/embedded cases.
if(catalinaHome==null) {
catalinaHome=System.getProperty("user.dir");
}
}
System.setProperty(Globals.CATALINA_BASE_PROP, catalinaBase);
}
-
+
String temp = System.getProperty("java.io.tmpdir");
if (temp == null || (!(new File(temp)).exists())
|| (!(new File(temp)).isDirectory())) {
}
-
+
protected void initStreams() {
// Replace System.out and System.err with a custom PrintStream
SystemLogHandler systemlog = new SystemLogHandler(System.out);
System.setErr(systemlog);
}
-
+
protected void initNaming() {
// Setting additional variables
if (!useNaming) {
}
}
-
+
/**
* Set the security package access/protection.
*/
securityConfig.setPackageDefinition();
securityConfig.setPackageAccess();
}
-
-
+
+
// --------------------------------------- CatalinaShutdownHook Inner Class
// XXX Should be moved to embedded !
}
}
}
-
-
+
+
private static final org.apache.juli.logging.Log log=
org.apache.juli.logging.LogFactory.getLog( Catalina.class );