Application Server Solutions for Microsoft IIS and ASP.NET
       solutions   products   partners   company   support   downloads         store
JTurbo Self-Help: FAQ
Back to Search >  Back to Search Results

Faq ID 241
Product ServletExec
Category XML
Question I'm using JDK 1.4 and trying to use newer XML classes than the ones that came with SE. It's not working, what's going on ?
Answer JDK 1.4 comes with it's own XML parsing and transforming classes (i.e. those typically found in xerces.jar and xalan.jar).
It appears that these classes reside in the rt.jar for JDK 1.4. Furthermore, JDK 1.4 is rigged to *always* use it's built-in versions except under special circumstances which this FAQ will attempt to describe. (Note: this may also apply to newer versions of the JDK, use the EnvironmentCheck utility described below to find out).
That in itself is not a bad thing, unless you wish to use a newer version of these XML classes. Please read info. about this here.

From this info. and our testing, we have found that the XML classes that come with SE will be ignored (we found this out in April of 2004) and the XML classes that come with JDK 1.4 will be used instead... unless you use one of the following workarounds:
  1. You put the versions you want to be used (both interfaces and their implementations) in your webapp's lib folder. This works because SE's own custom classloader will look there first, before it asks the System classloader to find them.
  2. You use the Endorsed Standards Override Mechanism as described at the above link.
  3. You prepend the updated xalan.jar, xercesImpl.jar, and xml-apis.jar to the boot class path as described at the link above.

Here is a JSP that ran fine in our SE 5.0 installation.
It uses the Xalan-Java's EnvironmentCheck utility described at the above link.
****
<%@page import="org.apache.xalan.xslt.EnvironmentCheck,java.io.*" %>
<%
 ServletOutputStream sos = response.getOutputStream();
 PrintWriter writer = new PrintWriter(sos);

 String s1 =  "<html> <p>   Here is the result from running Xalan-Java's EnvironmentCheck utility:</p> <p>  <pre>";

 writer.write(s1);

 boolean environmentOK = (new EnvironmentCheck()).checkEnvironment(writer);
%>


 </pre>
</p>

<p>  environmentOK=<%=environmentOK%> </p>

<p>You can learn more about the EnvironmentCheck utility from the following 2 links:<br>
<a href='http://xml.apache.org/xalan-j/faq.html#environmentcheck'>http://xml.apache.org/xalan-j/faq.html#environmentcheck</a>
<br>
<a href='http://xml.apache.org/xalan-j/faq.html#faq-N100CC'>http://xml.apache.org/xalan-j/faq.html#faq-N100CC</a>
</p></html>
 

****
The browser output from the above JSP told us that our J2SDK 1.4.2_04 installation was using:
 version.xerces2=Xerces-J 2.3.0
 version.xalan2_2=Xalan Java 2.4.1
  
Even if we placed newer versions of xalan.jar, xercesImpl.jar, and xml-apis.jar in SE's lib folder or on the Main SE classpath. We found that we could only get the utility to state a newer version of these classes if we placed the newer versions at:
C:\j2sdk1.4.2_04\jre\lib\endorsed
In other words, we applied one of the workarounds given above and confirmed that it worked.

If you wish your code running inside SE to use a newer XML class, you should be aware of this caveat that's caused by the JDK, and utilize the above utility together with the listed workarounds to figure out what's going on in your case, and how best to fix it for your own environment.



   
company media information terms of use privacy policy contact us