Author: mmusaji
Date: 2011-11-18 12:03:59 -0500 (Fri, 18 Nov 2011)
New Revision: 1869
Modified:
branches/JBOSSWEB_2_1_11_GA_JBPAPP-7549/java/org/apache/jasper/xmlparser/ParserUtils.java
Log:
JBPAPP-7549 - added fix to ParserUtils.java to wrap calls to no-arg calls with TCCL
push-pop to jaspers defining class loader
Modified:
branches/JBOSSWEB_2_1_11_GA_JBPAPP-7549/java/org/apache/jasper/xmlparser/ParserUtils.java
===================================================================
---
branches/JBOSSWEB_2_1_11_GA_JBPAPP-7549/java/org/apache/jasper/xmlparser/ParserUtils.java 2011-11-18
15:59:20 UTC (rev 1868)
+++
branches/JBOSSWEB_2_1_11_GA_JBPAPP-7549/java/org/apache/jasper/xmlparser/ParserUtils.java 2011-11-18
17:03:59 UTC (rev 1869)
@@ -86,11 +86,11 @@
// Perform an XML parse of this document, via JAXP
try {
- DocumentBuilderFactory factory =
- DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(true);
+ DocumentBuilderFactory factory =
+ createDocumentBuilderFactory();
+ factory.setNamespaceAware(true);
factory.setValidating(validating);
- DocumentBuilder builder = factory.newDocumentBuilder();
+ DocumentBuilder builder = newDocumentBuilder(factory);
builder.setEntityResolver(entityResolver);
builder.setErrorHandler(errorHandler);
document = builder.parse(is);
@@ -184,9 +184,38 @@
// Return the completed TreeNode graph
return (treeNode);
}
+
+ protected static DocumentBuilderFactory createDocumentBuilderFactory()
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ DocumentBuilderFactory factory;
+ try
+ {
+ Thread.currentThread().setContextClassLoader(ParserUtils.class.getClassLoader());
+ factory = DocumentBuilderFactory.newInstance();
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+ return factory;
+ }
+
+ protected static DocumentBuilder newDocumentBuilder(DocumentBuilderFactory factory)
throws ParserConfigurationException
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ Thread.currentThread().setContextClassLoader(ParserUtils.class.getClassLoader());
+ return factory.newDocumentBuilder();
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+ }
}
-
// ------------------------------------------------------------ Private Classes
class MyEntityResolver implements EntityResolver {
Show replies by date