ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 46172] New: xslt task's factory attribute broken: TraXLiaison uses incorrect class loader.
Date Sun, 09 Nov 2008 20:25:59 GMT
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: notifications@ant.apache.org
        ReportedBy: dawid.weiss@cs.put.poznan.pl


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.

Mime
View raw message