import java.net.URLConnection;
import javax.imageio.ImageIO;
-import javax.security.auth.Policy;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
*/
if (securityPolicyProtection) {
try {
- Policy.getPolicy();
+ // Policy.getPolicy();
+ Class<?> policyClass = Class
+ .forName("javax.security.auth.Policy");
+ Method method = policyClass.getMethod("getPolicy");
+ method.invoke(null);
+ } catch(ClassNotFoundException e) {
+ // Ignore. The class is deprecated.
} catch(SecurityException e) {
// Ignore. Don't need call to getPolicy() to be successful,
// just need to trigger static initializer.
+ } catch (NoSuchMethodException e) {
+ log.warn(sm.getString("jreLeakListener.authPolicyFail"), e);
+ } catch (IllegalArgumentException e) {
+ log.warn(sm.getString("jreLeakListener.authPolicyFail"), e);
+ } catch (IllegalAccessException e) {
+ log.warn(sm.getString("jreLeakListener.authPolicyFail"), e);
+ } catch (InvocationTargetException e) {
+ log.warn(sm.getString("jreLeakListener.authPolicyFail"), e);
}
}
jreLeakListener.gcDaemonFail=Failed to trigger creation of the GC Daemon thread during Tomcat start to prevent possible memory leaks. This is expected on non-Sun JVMs.
jreLeakListener.jarUrlConnCacheFail=Failed to disable Jar URL connection caching by default
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
naming.wsdlFailed=Failed to find wsdl file: {0}
naming.bindFailed=Failed to bind object: {0}
naming.jmxRegistrationFailed=Failed to register in JMX: {0}
</attribute>
<attribute name="securityPolicyProtection" required="false">
- <p>Enables protection so that usage of
- <code>javax.security.auth.Policy</code> by a web application does not
+ <p>Enables protection so that usage of the deprecated
+ <code>javax.security.auth.Policy</code> class by a web application does not
result in a memory leak. The first access of this class will trigger the
static initializer that will retain a static reference to the context
class loader. The protection calls the <code>getPolicy()</code> method