remm 2005/08/01 05:13:59
Modified: catalina/src/share/org/apache/catalina/core
AprLifecycleListener.java LocalStrings.properties
Log:
- Add version check for Tomcat native.
Revision Changes Path
1.3 +25 -3
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/AprLifecycleListener.java
Index: AprLifecycleListener.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/AprLifecycleListener.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AprLifecycleListener.java 27 May 2005 10:04:43 -0000 1.2
+++ AprLifecycleListener.java 1 Aug 2005 12:13:59 -0000 1.3
@@ -46,6 +46,15 @@
protected StringManager sm =
StringManager.getManager(Constants.Package);
+
+ // --------------------------------------------------------------
Constants
+
+
+ protected static final int REQUIRED_MAJOR = 1;
+ protected static final int REQUIRED_MINOR = 1;
+ protected static final int REQUIRED_PATCH = 0;
+
+
// ---------------------------------------------- LifecycleListener
Methods
@@ -57,15 +66,21 @@
public void lifecycleEvent(LifecycleEvent event) {
if (Lifecycle.INIT_EVENT.equals(event.getType())) {
+ int major = 0;
+ int minor = 0;
+ int patch = 0;
try {
String methodName = "initialize";
Class paramTypes[] = new Class[1];
paramTypes[0] = String.class;
Object paramValues[] = new Object[1];
paramValues[0] = null;
- Method method =
Class.forName("org.apache.tomcat.jni.Library")
- .getMethod(methodName, paramTypes);
+ Class clazz = Class.forName("org.apache.tomcat.jni.Library");
+ Method method = clazz.getMethod(methodName, paramTypes);
method.invoke(null, paramValues);
+ major = clazz.getField("TCN_MAJOR_VERSION").getInt(null);
+ minor = clazz.getField("TCN_MINOR_VERSION").getInt(null);
+ patch = clazz.getField("TCN_PATCH_VERSION").getInt(null);
} catch (Throwable t) {
if (!log.isDebugEnabled()) {
log.info(sm.getString("aprListener.aprInit",
@@ -74,6 +89,13 @@
log.debug(sm.getString("aprListener.aprInit",
System.getProperty("java.library.path")), t);
}
+ return;
+ }
+ if ((major != REQUIRED_MAJOR) || (minor != REQUIRED_MINOR)
+ || (patch < REQUIRED_PATCH)) {
+ log.error(sm.getString("aprListener.tcnInvalid", major + "."
+ + minor + "." + patch, REQUIRED_MAJOR + "."
+ + REQUIRED_MINOR + "." + REQUIRED_PATCH));
}
} else if (Lifecycle.AFTER_STOP_EVENT.equals(event.getType())) {
try {
1.23 +1 -0
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/LocalStrings.properties
Index: LocalStrings.properties
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/LocalStrings.properties,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- LocalStrings.properties 27 May 2005 09:41:38 -0000 1.22
+++ LocalStrings.properties 1 Aug 2005 12:13:59 -0000 1.23
@@ -15,6 +15,7 @@
applicationResponse.badParent=Cannot locate parent Response implementation
applicationResponse.badResponse=Response is not a
javax.servlet.ServletResponseWrapper
aprListener.aprInit=The Apache Portable Runtime which allows optimal
performance in production environments was not found on the java.library.path:
{0}
+aprListener.tcnInvalid=An incompatible version {0} of the Tomcat Native
library is installed, while Tomcat requires version {1}
aprListener.aprDestroy=Failed shutdown of Apache Portable Runtime
containerBase.addDefaultMapper=Exception configuring default mapper of class
{0}
containerBase.alreadyStarted=Container {0} has already been started
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]