https://issues.apache.org/bugzilla/show_bug.cgi?id=46172
Summary: xslt task's factory attribute broken: TraXLiaison uses
incorrect class loader.
Product: Ant
Version: unspecified
Platform: All
OS/Version: All
Status: NEW
Severity: trivial
Priority: P2
Component: Optional Tasks
AssignedTo: [email protected]
ReportedBy: [EMAIL PROTECTED]
Created an attachment (id=22845)
--> (https://issues.apache.org/bugzilla/attachment.cgi?id=22845)
A diff against ANT_17_BRANCH
XSLT processing tasks allows one to specify custom transformer factory,
including a custom class path for this factory's classes. This is very handy
as it allows custom XSLT processor to be embedded in the project. However, when
used, it throws ClassNotFoundExceptions from TraXLiaison (1.6.x, 1.7.x, head).
The bug is caused by the following snippet in TraXLiaison:
private TransformerFactory getFactory() throws BuildException {
// ... [SNIP]
try {
Class clazz = Class.forName(factoryName);
tfactory = (TransformerFactory) clazz.newInstance();
} catch (Exception e) {
// ... [SNIP]
XSLT task sets a custom context class loader, but it is not used here, because
Class.forName(String) is equivalent to calling:
Class.forName(String, definingClass.getClassLoader());
In other words, ANT's class loader is used to look up the class where context
class loader should be used (this is a common mistake). This can be fixed in a
number of ways -- by using Class.forName(String,
Thread.currentThread().getContextClassLoader()) or by using the context class
loader explicitly (as in the attached patch).
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.