Freeman, This is definitely not a "complete" fix. With the way we setup the TCK, this will result in a new ParserFactory being created almost all the time which will suck. The main reason is that the Thread contextClassLoader is the webapps classloader, but the parser is loaded from the tomcat classloader which would be one of the parents of the contextClassloader.
Thus, the fix probably should check the parents of the contextClassLoader as well. Dan On Thursday 03 January 2008, [EMAIL PROTECTED] wrote: > Author: ffang > Date: Wed Jan 2 23:42:20 2008 > New Revision: 608369 > > URL: http://svn.apache.org/viewvc?rev=608369&view=rev > Log: > [CXF-1351] static DocumentBuilderFactory in XMLUtils cause > ClassCastException when use different classloader > > Modified: > > incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers >/XMLUtils.java > > Modified: > incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers >/XMLUtils.java URL: > http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/mai >n/java/org/apache/cxf/helpers/XMLUtils.java?rev=608369&r1=608368&r2=608 >369&view=diff > ====================================================================== >======== --- > incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers >/XMLUtils.java (original) +++ > incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers >/XMLUtils.java Wed Jan 2 23:42:20 2008 @@ -88,6 +88,13 @@ > } > > public static DocumentBuilder getParser() throws > ParserConfigurationException { + if > (parserFactory.getClass().getClassLoader() != null + && > !parserFactory.getClass().getClassLoader().equals( + > Thread.currentThread().getContextClassLoader())) { + //not > the same classloader which init parserFactory, so create parserFactory > with new classLoader + parserFactory = > DocumentBuilderFactory.newInstance(); + > parserFactory.setNamespaceAware(true); > + } > return parserFactory.newDocumentBuilder(); > } -- J. Daniel Kulp Principal Engineer, IONA [EMAIL PROTECTED] http://www.dankulp.com/blog
