Hi all,

With <http://eis.services.openoffice.org/EIS2/cws.ShowCWS?Path=SRC680%2Fsb36> integrated in SRC680m206, the following problem can pop up (see <http://www.openoffice.org/issues/show_bug.cgi?id=75767>):

Some Java APIs (like <http://java.sun.com/javase/6/docs/api/javax/xml/transform/TransformerFactory.html#newInstance()>) utilize the context class loader (see <http://java.sun.com/javase/6/docs/api/java/lang/Thread.html#getContextClassLoader()>). If you do not explicitly set a context class loader, the default context class loader is the application class loader, feeding from the JVM's global class path.

Until SRC680m205, program/classes/XSLTFilter.jar (among others) was on the global class path, and XSLTFilter.jar has program/classes/xalan.jar on its MANIFEST.MF Class-Path, so indirectly the application class loader (which is also the default context class loader) saw xalan.jar's META-INF/services/javax.xml.transform.TransformerFactory, and thus javax.xml.transform.TransformerFactory.newInstance() instantiated a transformer from the xalan.jar.

Since SRC680m206, the global class path is effectively empty, so the application class loader does not see any transformer factories advertising themselves, so javax.xml.transform.TransformerFactory.newInstance() falls back to instantiate a transformer coming with the JRE itself. As it turned out for issue 75767, that transformer is less capable than the one from xalan.jar, so an error occurred.

The solution is as follows: When you are using some such Java factory API (javax.xml.parsers.DocumentBuilderFactory, javax.xml.parsers.SAXParserFactory, javax.xml.transform.TransformerFactory come to mind, but there are probably others, too) and the actual factory resolution is crucial, do not make your code depend on assumptions about the global class path, but explicitly set an appropriate context class loader around the factory call.

Please everybody review any OOo code you feel responsible for and check whether it is prone to this problem. (This can hardly be done automatically: For one, the list of potential factories to grep for is unknown. For another, in each factory use case it is unclear whether or not a specific instance should be chosen.)

-Stephan

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to