DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=41314>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=41314

           Summary: Xslt task's <factory> nested element always causes
                    ClassNotFoundException
           Product: Ant
           Version: 1.7.0
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core tasks
        AssignedTo: [email protected]
        ReportedBy: [EMAIL PROTECTED]


CONTEXT

For the Xslt task, it is sometimes necessary to specify an alternate processor, 
such as Saxon. The usual 
way to do this is via the classpath attribute of the Xslt task. Simply adding 
the Saxon JAR to this attribute 
allows Ant to find, load, and use the Saxon processor.

PROBLEM

If a Xalan processor happens to be listed in the CLASSPATH environment 
variable, this technique does 
not work. Xalan, not Saxon, is used instead. It appears that CLASSPATH trumps 
Xslt's classpath attribute. 
(Note that those who've installed Ant via the Fink package manager have Xalan 
in their CLASSPATH by 
default, so this is not an uncommon situation.)

WORKAROUNDS

There are three workarounds for this problem:

1) Alter the CLASSPATH variable so that the Saxon JAR is listed before Xalan
2) Add the parameter "-lib <path-to-Saxon-JAR>" when calling Ant on the command 
line
3) Use the <factory> sub-element of the Xslt task to specify the Saxon factory 
class explicitly, thus 
overriding Xalan.

The first two workarounds are unsatisfactory because they impose an artificial 
requirement on users to 
adjust their Ant startup classpath. As for the third workaround, it does not 
work at all; it always results 
in a ClassNotFoundException.

TEST CASE

The attached test case reproduces the ClassNotFoundException of workaround #3. 
It has been verified 
on the 2007-01-06 nightly build. To reproduce:

1) Download the test case and extract the archive to a directory of your choice
2) Make sure your system's CLASSPATH environment variable is empty
3) Switch to that directory and run "ant". The Saxon processor will be used in 
the transformation, as 
indicated by the warning "Running an XSLT 1.0 stylesheet with an XSLT 2.0 
processor". This is the 
expected behavior because the Saxon JAR is specified in the Xslt task's 
classpath attribute.
4) Add the provided Xalan JAR to your system's CLASSPATH environment variable. 
(e.g., "export 
CLASSPATH=xalan-2.7.0.jar")
5) Run "ant" again. The Xalan processor is used, which is not the desired 
behavior.
6) Attempt to workaround this problem by uncommenting the <factory> nested 
element in build.xml 
(line 12).
7) Run "ant" again. You will see an error: "java.lang.ClassNotFoundException: 
net.sf.saxon.TransformerFactoryImpl".

This is not the expected behavior because the class is contained in the 
provided Saxon JAR, and this JAR 
is listed in Xslt's classpath attribute.

REFERENCES

This issue is discussed in the Ant FAQ:

http://ant.apache.org/faq.html#delegating-classloader

However, the workaround given in the FAQ requires the user to alter the Ant 
installation. This is a 
burden for users and should not be necessary. In fact, it has been eliminated 
in Ant 1.7.0, but only for 
the <junit> task, as described in bug #38799. The Xslt task still needs to be 
fixed.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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

Reply via email to