0

I asked this question in several flavors, and I think I'm not asking the right question. I'm suspecting now that Xalan, since it's implementing a Java endorsed standard, can only have one implementation at a given VM / ClassLoader.

So is it true? can't 2 Xalan implementaions "live" in the same System ClassLoader? Or if they can, How?

Community
  • 1
  • 1
Eran Medan
  • 44,555
  • 61
  • 184
  • 276

2 Answers2

1

This seems to be the surprising answer:

For each Xalan implementation use a seperate classloader, and add a file in

META-INF\services\ called

javax.xml.transform.TransformerFactory

Edit it and put it's only content the Xalan implementation the class loader will use, e.g.:

com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl

NOTE: The nice thing here is that as opposed to the regular class loading delegation, META-INF\services is being searched in the current class loader first, where as classes are being search in the parent, then system, and only then in the child classloder

Eran Medan
  • 44,555
  • 61
  • 184
  • 276
  • See also: http://stackoverflow.com/questions/5447633/how-to-prevent-xalan-jar-that-has-meta-inf-services-javax-xml-transform-transform – Eran Medan Mar 27 '11 at 09:06
0

There is some xalan version included in the jdk. For most usages, my personal experience is that using this version is enough. Even if it could be a previous version, is there any new xalan development nowadays? I prefer using the included, strongly tested version.

I don't think having to xsl transformers in the same jdk is a good idea (even if I guess it can be done). If you really need to use some updated version of xalan, instead of the jdk one, you could referer to this faq: http://xml.apache.org/xalan-j/faq.html#faq-N100EF

I stripped all specific xalan dependencies in big applications, using just the embedded one. Libraries as FOP, although they previously pretended to require some specific xalan jar, ran just fine without it, and it solved a lot of class loading issues (java ee app server giving problems in some situations when xalan was packaged).

ymajoros
  • 2,454
  • 3
  • 34
  • 60
  • I have XSLs that work only on an old Xalan due to some deprecated API's I guess, and since they are already installed at clients I cant even fix them. But using that old Xalan, some new iText functionality doesn't work... so my solution is running it as a separate JVM process completely – Eran Medan May 06 '11 at 04:39