Fix resource loading problem in Cocoon.
Note: this apparently fixes properly the fix that garyp attempted to
add 21-May-01; however JDK 118 and 122 behave differently when
calling getResourceAsStream, so in the 118 case I've had to
prepend a hard-coded / slash char: this should be reviewed later
PR: email on xalan-dev
Submitted by: dims@yahoo.com
diff --git a/src/org/apache/xalan/processor/TransformerFactoryImpl.java b/src/org/apache/xalan/processor/TransformerFactoryImpl.java
index 2d25065..1da9b21 100644
--- a/src/org/apache/xalan/processor/TransformerFactoryImpl.java
+++ b/src/org/apache/xalan/processor/TransformerFactoryImpl.java
@@ -112,9 +112,12 @@
public class TransformerFactoryImpl extends SAXTransformerFactory
{
- /** The Xalan properties file. */
+ /**
+ * The path/filename of the property file: XSLTInfo.properties
+ * Maintenance note: see also org.apache.xpath.functions.FuncSystemProperty.XSLT_PROPERTIES
+ */
public static String XSLT_PROPERTIES =
- "/org/apache/xalan/res/XSLTInfo.properties";
+ "org/apache/xalan/res/XSLTInfo.properties";
/** Flag tells if the properties file has been loaded to the system */
private static boolean isInited = false;
@@ -164,13 +167,16 @@
java.lang.reflect.Method getCCL = Thread.class.getMethod("getContextClassLoader", NO_CLASSES);
if (getCCL != null) {
ClassLoader contextClassLoader = (ClassLoader) getCCL.invoke(Thread.currentThread(), NO_OBJS);
- is = contextClassLoader.getResourceAsStream("org/apache/xalan/processor/" + file);
+ is = contextClassLoader.getResourceAsStream(file); // file should be already fully specified
}
}
catch (Exception e) {}
if (is == null) {
- is = TransformerFactoryImpl.class.getResourceAsStream(file);
+ // NOTE! For the below getResourceAsStream in Sun JDK 1.1.8M
+ // we apparently must add the leading slash character - I
+ // don't know why, but if it's not there, we throw an NPE from the below loading
+ is = TransformerFactoryImpl.class.getResourceAsStream("/" + file); // file should be already fully specified
}
// get a buffered version
diff --git a/src/org/apache/xpath/functions/FuncSystemProperty.java b/src/org/apache/xpath/functions/FuncSystemProperty.java
index 22c63a1..05e67cb 100644
--- a/src/org/apache/xpath/functions/FuncSystemProperty.java
+++ b/src/org/apache/xpath/functions/FuncSystemProperty.java
@@ -83,8 +83,11 @@
public class FuncSystemProperty extends FunctionOneArg
{
- /** The name of the property file where the name will be stored. */
- static String XSLT_PROPERTIES = "/org/apache/xalan/res/XSLTInfo.properties";
+ /**
+ * The path/filename of the property file: XSLTInfo.properties
+ * Maintenance note: see also org.apache.xalan.processor.TransformerFactoryImpl.XSLT_PROPERTIES
+ */
+ static String XSLT_PROPERTIES = "org/apache/xalan/res/XSLTInfo.properties";
/** a zero length Class array used in loadPropertyFile() */
private static final Class[] NO_CLASSES = new Class[0];
@@ -205,8 +208,8 @@
/**
* Retrieve a propery bundle from a specified file
*
- * @param file The string name of the property file. The file is loaded from
- * the workplace base directory
+ * @param file The string name of the property file. The name
+ * should already be fully qualified as path/filename
* @param target The target property bag the file will be placed into.
*/
public void loadPropertyFile(String file, Properties target)
@@ -220,13 +223,17 @@
java.lang.reflect.Method getCCL = Thread.class.getMethod("getContextClassLoader", NO_CLASSES);
if (getCCL != null) {
ClassLoader contextClassLoader = (ClassLoader) getCCL.invoke(Thread.currentThread(), NO_OBJS);
- is = contextClassLoader.getResourceAsStream("org/apache/xpath/functions/" + file);
+ is = contextClassLoader.getResourceAsStream(file); // file should be already fully specified
}
}
catch (Exception e) {}
- if (is == null);
- is = FuncSystemProperty.class.getResourceAsStream(file);
+ if (is == null) {
+ // NOTE! For the below getResourceAsStream in Sun JDK 1.1.8M
+ // we apparently must add the leading slash character - I
+ // don't know why, but if it's not there, we throw an NPE from the below loading
+ is = FuncSystemProperty.class.getResourceAsStream("/" + file); // file should be already fully specified
+ }
// get a buffered version
BufferedInputStream bis = new BufferedInputStream(is);