tldConfig.cce=Lifecycle event data object {0} is not a Context
tldConfig.classloaderFail=Failed to process ''{0}'' for TLDs.
tldConfig.classloaderStart=Scanning for TLDs in classloader hierarchy
+tldConfig.dirScan=Scanning for TLD files in directory ''{0}''
tldConfig.execute=Error processing TLD files for context path {0}
tldConfig.jarUrlStart=Scanning for TLD files in URL ''{0}''
tldConfig.webinflibStart=Scanning WEB-INF/lib for JARs containing META-INF/**/*.TLD
package org.apache.catalina.startup;
+import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.JarURLConnection;
+import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLConnection;
"org.apache.jasper.compiler.TldLocationsCache.SCAN_CLASSPATH",
"true")).booleanValue();
+ private static final boolean SCAN_ALL_FILES = Boolean.valueOf(
+ System.getProperty(
+ "org.apache.jasper.compiler.TldLocationsCache.SCAN_ALL_FILES",
+ "false")).booleanValue();
+
+ private static final boolean SCAN_ALL_DIRS = Boolean.valueOf(
+ System.getProperty(
+ "org.apache.jasper.compiler.TldLocationsCache.SCAN_ALL_DIRS",
+ "false")).booleanValue();
+
// Names of JARs that are known not to contain any TLDs
private static HashSet<String> noTldJars;
tldScanJar((JarURLConnection) conn);
} else {
String urlStr = url.toString();
- if (urlStr.startsWith("file:")
- && urlStr.endsWith(JAR_EXT)) {
- URL jarURL = new URL("jar:" + urlStr + "!/");
- tldScanJar((JarURLConnection) jarURL.openConnection());
+ if (urlStr.startsWith("file:")) {
+ if (urlStr.endsWith(JAR_EXT)) {
+ URL jarURL = new URL("jar:" + urlStr + "!/");
+ tldScanJar((JarURLConnection) jarURL.openConnection());
+ } else {
+ File f;
+ try {
+ f = new File(url.toURI());
+ if (f.isFile() && SCAN_ALL_FILES) {
+ // Treat this file as a JAR
+ URL jarURL = new URL("jar:" + urlStr + "!/");
+ tldScanJar((JarURLConnection) jarURL.openConnection());
+ } else if (f.isDirectory() && SCAN_ALL_DIRS) {
+ File metainf = new File(f.getAbsoluteFile() +
+ File.separator + "META-INF");
+ if (metainf.isDirectory()) {
+ tldScanDir(metainf);
+ }
+ }
+ } catch (URISyntaxException e) {
+ // Wrap the exception and re-throw
+ IOException ioe = new IOException();
+ ioe.initCause(e);
+ throw ioe;
+ }
+ }
+ }
+ }
+ }
+
+ /*
+ * Scans the directory identified by startPath, along with its
+ * sub-directories, for TLDs.
+ *
+ * Keep in sync with o.a.j.comiler.TldLocationsCache
+ */
+ private void tldScanDir(File start) {
+
+ if (log.isTraceEnabled()) {
+ log.trace(sm.getString("tldConfig.dirScan", start.getAbsolutePath()));
+ }
+
+ File[] fileList = start.listFiles();
+ if (fileList != null) {
+ for (int i = 0; i < fileList.length; i++) {
+ // Scan recursively
+ if (fileList[i].isDirectory()) {
+ tldScanDir(fileList[i]);
+ } else if (fileList[i].getAbsolutePath().endsWith(TLD_EXT)) {
+ InputStream stream = null;
+ try {
+ stream = new FileInputStream(fileList[i]);
+ tldScanStream(stream);
+ } catch (IOException ioe) {
+ log.warn(sm.getString("tldConfig.dirFail",
+ fileList[i].getAbsolutePath()),
+ ioe);
+ } finally {
+ if (stream != null) {
+ try {
+ stream.close();
+ } catch (Throwable t) {
+ // do nothing
+ }
+ }
+ }
+ }
}
}
}
package org.apache.jasper.compiler;
+import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
// the following is a workaround until these problems are resolved.
private InputStream getResourceAsStream(String uri)
throws FileNotFoundException {
- try {
- // see if file exists on the filesystem first
- String real = ctxt.getRealPath(uri);
- if (real == null) {
+ // Is uri absolute?
+ if (uri.startsWith("file:")) {
+ return new FileInputStream(new File(uri.substring(5)));
+ } else {
+ try {
+ // see if file exists on the filesystem
+ String real = ctxt.getRealPath(uri);
+ if (real == null) {
+ return ctxt.getResourceAsStream(uri);
+ } else {
+ return new FileInputStream(real);
+ }
+ } catch (FileNotFoundException ex) {
+ // if file not found on filesystem, get the resource through
+ // the context
return ctxt.getResourceAsStream(uri);
- } else {
- return new FileInputStream(real);
}
- } catch (FileNotFoundException ex) {
- // if file not found on filesystem, get the resource through
- // the context
- return ctxt.getResourceAsStream(uri);
}
-
}
/**
package org.apache.jasper.compiler;
+import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.JarURLConnection;
import java.net.MalformedURLException;
+import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLConnection;
"org.apache.jasper.compiler.TldLocationsCache.SCAN_CLASSPATH",
"true")).booleanValue();
+ private static final boolean SCAN_ALL_FILES = Boolean.valueOf(
+ System.getProperty(
+ "org.apache.jasper.compiler.TldLocationsCache.SCAN_ALL_FILES",
+ "false")).booleanValue();
+
+ private static final boolean SCAN_ALL_DIRS = Boolean.valueOf(
+ System.getProperty(
+ "org.apache.jasper.compiler.TldLocationsCache.SCAN_ALL_DIRS",
+ "false")).booleanValue();
+
// Names of JARs that are known not to contain any TLDs
private static HashSet<String> noTldJars;
tldScanJar((JarURLConnection) conn);
} else {
String urlStr = url.toString();
- if (urlStr.startsWith(FILE_PROTOCOL)
- && urlStr.endsWith(JAR_EXT)) {
- URL jarURL = new URL("jar:" + urlStr + "!/");
- tldScanJar((JarURLConnection) jarURL.openConnection());
+ if (urlStr.startsWith("file:")) {
+ if (urlStr.endsWith(JAR_EXT)) {
+ URL jarURL = new URL("jar:" + urlStr + "!/");
+ tldScanJar((JarURLConnection) jarURL.openConnection());
+ } else {
+ File f;
+ try {
+ f = new File(url.toURI());
+ if (f.isFile() && SCAN_ALL_FILES) {
+ // Treat this file as a JAR
+ URL jarURL = new URL("jar:" + urlStr + "!/");
+ tldScanJar((JarURLConnection) jarURL.openConnection());
+ tldScanJar((JarURLConnection) jarURL.openConnection());
+ } else if (f.isDirectory() && SCAN_ALL_DIRS) {
+ File metainf = new File(f.getAbsoluteFile() +
+ File.separator + "META-INF");
+ if (metainf.isDirectory()) {
+ tldScanDir(metainf);
+ }
+ }
+ } catch (URISyntaxException e) {
+ // Wrap the exception and re-throw
+ IOException ioe = new IOException();
+ ioe.initCause(e);
+ throw ioe;
+ }
+ }
+ }
+ }
+ }
+
+ /*
+ * Scans the directory identified by startPath, along with its
+ * sub-directories, for TLDs.
+ *
+ * Keep in sync with o.a.c.startup.TldConfig
+ */
+ private void tldScanDir(File start) throws IOException {
+
+ File[] fileList = start.listFiles();
+ if (fileList != null) {
+ for (int i = 0; i < fileList.length; i++) {
+ // Scan recursively
+ if (fileList[i].isDirectory()) {
+ tldScanDir(fileList[i]);
+ } else if (fileList[i].getAbsolutePath().endsWith(TLD_EXT)) {
+ InputStream stream = null;
+ try {
+ stream = new FileInputStream(fileList[i]);
+ tldScanStream(
+ fileList[i].toURI().toString(), null, stream);
+ } finally {
+ if (stream != null) {
+ try {
+ stream.close();
+ } catch (Throwable t) {
+ // do nothing
+ }
+ }
+ }
+ }
}
}
}
be used.</p>
</property>
+ <property name="org.apache.jasper.compiler. TldLocationsCache.SCAN_ALL_FILES">
+ <p>When scanning the class path for TLDs, should Jasper scan all files
+ as if they are JAR files even if they do not have a .jar file extension?
+ This is intended for use in embedded environments where custom
+ classloaders allow for archives on the classpath with non-standard file
+ extensions. If not specified, the default value of <code>false</code> will
+ be used.</p>
+ </property>
+
+ <property name="org.apache.jasper.compiler. TldLocationsCache.SCAN_ALL_DIRS">
+ <p>When scanning the class path for TLDs, should Jasper scan all
+ directories as if they are unpacked JAR files? This is intended for use in
+ embedded environments where custom classloaders allow for directories
+ representing unpacked WAR files on the classpath. If not specified, the
+ default value of <code>false</code> will be used.</p>
+ </property>
+
<property name="org.apache.jasper.runtime. BodyContentImpl.LIMIT_BUFFER">
<p>If <code>true</code>, any tag buffer that expands beyond
<code>org.apache.jasper.Constants.DEFAULT_TAG_BUFFER_SIZE</code> will be