On Windows 7 I have an ant target that copies a xalan library into the jdk endorsed directory so that the next xslt transformation task can occur.
The first time that the ant target runs, the xslt transformation fails. The second time it runs the jar file is already in the correct place and the xslt tranformation succeeds.
The first time that the ant target runs, it looks like the file copied successfully. It feels like a timing issue, but I don’t know what I can do to get around it.
Here is my copy task:
<mkdir dir="${java.home}\lib\endorsed"/>
<copy file="${basedir}\xalan.jar" tofile="${java.home}\lib\endorsed\xalan.jar"/>
Has anyone seen anything like this before?
I think the problem is that when the XSLT task is executes, the JVM (which runs Ant itself) has already loaded classes from the endorsed directory. You would have to fork another JVM instance after having copied the xalan jar into the endorsed dir.
What are you using to run xslt? If it’s the XSLT task, couldn’t you just use the factory element in order to load xalan ? If it’s a java task, then use the fork attribute to start the xslt processing in another JVM instance.