import java.net.URL;
import java.net.URLConnection;
import java.sql.DriverManager;
+import java.util.StringTokenizer;
import javax.imageio.ImageIO;
import javax.xml.parsers.DocumentBuilderFactory;
public void setDriverManagerProtection(boolean driverManagerProtection) {
this.driverManagerProtection = driverManagerProtection;
}
-
+
+ /**
+ * List of comma-separated fully qualified class names to load and initialize during
+ * the startup of this Listener. This allows to pre-load classes that are known to
+ * provoke classloader leaks if they are loaded during a request processing.
+ */
+ private String classesToInitialize = null;
+ public String getClassesToInitialize() {
+ return classesToInitialize;
+ }
+ public void setClassesToInitialize(String classesToInitialize) {
+ this.classesToInitialize = classesToInitialize;
+ }
+
+
@Override
public void lifecycleEvent(LifecycleEvent event) {
// Initialise these classes when Tomcat starts
}
}
}
+
+ if (classesToInitialize != null) {
+ StringTokenizer strTok =
+ new StringTokenizer(classesToInitialize, ", \r\n\t");
+ while (strTok.hasMoreTokens()) {
+ String classNameToLoad = strTok.nextToken();
+ try {
+ Class.forName(classNameToLoad);
+ } catch (ClassNotFoundException e) {
+ log.error(
+ sm.getString("jreLeakListener.classToInitializeFail",
+ classNameToLoad), e);
+ // continue with next class to load
+ }
+ }
+ }
} finally {
Thread.currentThread().setContextClassLoader(loader);
jreLeakListener.xmlParseFail=Error whilst attempting to prevent memory leaks during XML parsing
jreLeakListener.authPolicyFail=Error whilst attempting to prevent memory leak in javax.security.auth.Policy class
jreLeakListener.ldapPoolManagerFail=Failed to trigger creation of the com.sun.jndi.ldap.LdapPoolManager class during Tomcat start to prevent possible memory leaks. This is expected on non-Sun JVMs.
+jreLeakListener.classToInitializeFail=Failed to load class {0} during Tomcat start to prevent possible memory leaks.
naming.wsdlFailed=Failed to find wsdl file: {0}
naming.bindFailed=Failed to bind object: {0}
naming.jmxRegistrationFailed=Failed to register in JMX: {0}
Defaults to <code>false</code> because an AWT thread is launched.</p>
</attribute>
+ <attribute name="classesToInitialize" required="false">
+ <p>List of comma-separated fully qualified class names to load and initialize
+ during the startup of this Listener. This allows to pre-load classes that are
+ known to provoke classloader leaks if they are loaded during a request
+ processing. Non-JRE classes may be referenced, like
+ <code>oracle.jdbc.driver.OracleTimeoutThreadPerVM</code>.
+ The default value is empty, but specific JRE classes are loaded by other leak
+ protection features managed by other attributes of this Listener.</p>
+ </attribute>
+
<attribute name="driverManagerProtection" required="false">
<p>The first use of <code>java.sql.DriverManager</code> will trigger the
loading of JDBNC Driver in the the current class loader. The web