That isn't the issue here. Beginning with Tomcat-4.0.2, Tomcat is enforcing Sun's classloading spec more stringently and not allowing XML/DOM libraries to be loaded from a child classloader. In plain english, this means you cannot include XML/DOM libraries in WEB-INF/lib. They must exist in a parent classloader such as $TOMCAT_HOME/lib (or $TOMCAT_HOME/shared/lib in 4.1.x) or $TOMCAT_HOME/common/lib (or $TOMCAT_HOME/common/endorsed when using j2sdk1.4.x in Tomcat-4.1.x).
The reason why you get the ClassCastException is that although Tomcat is attempting to enforce the spec, it doesn't do it very cleanly. This was fixed for the 4.0.4 release as well as the latest releases of 4.1.x. Upgrade to 4.0.4 or 4.1.7 and move your XML/DOM libraries to the above mentioned directories and all will be well. Jake Quoting Andrew Conrad <[EMAIL PROTECTED]>: > This isn't answering your question as you posed it, but aren't > xml-api.jar and XMLParserAPI.jar from different versions of Xerces? > Xalan 2.4.D1 comes with Xerces 2.0.1 (xercesImpl.jar and xml-api.jar). > To use Xerces 2.0.2, aren't you suppose to delete those files and > replace them with those from the Xerces distribution (xercesImpl.jar and > XMLParserAPI.jar)? > > Maybe you are having a class loading issue because you are mixing your > versions. > > Just a thought. > > - Andrew > > > > -----Original Message----- > From: stephen chan [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, July 10, 2002 9:05 PM > To: 'Tomcat Users List' > Subject: Class loader problem with Xalan under 4.0.2 and 4.0.3 > > > Class loader problem with Xalan under 4.0.2 and 4.0.3 > > > Hi, I have: > > jakarta-tomcat-4.0.2 / jakarta-tomcat-4.0.3 > Xerces-J-bin.2.0.2 > xalan-j_2_4_D1-bin.tar.gz > jdom > sun jdk jdk1.3.1 > > on a linux box. > > According to Tomcat documentation, class loading is > done in the following order: > > /WEB-INF/classes of your web application > /WEB-INF/lib/*.jar of your web application > Bootstrap classes of your JVM > System class loader classses > $CATALINA_HOME/common/classes > $CATALINA_HOME/common/lib/*.jar > $CATALINA_HOME/classes > $CATALINA_HOME/lib/*.jar > > In my /WEB-INF/lib/ directory, I have all the > xerces, xalan and jdom jar files: > > BCEL.jar > JLex.jar > bsf.jar > java_cup.jar > jdom.jar > regexp.jar > runtime.jar > xalan.jar > xalansamples.jar > xalanservlet.jar > xercesImpl.jar > xercesSamples.jar > xml-apis.jar > xmlParserAPIs.jar > xsltc.jar > > When I run my servlet from /WEB-INF/classes, > I get this: > > root cause > > java.lang.NoClassDefFoundError: > javax/xml/transform/TransformerException > > This means Tomcat can't find the xalan lib. > *** Tomcat can find xerces and jdom libs *** > > At this point, I decided to do some testing on other versions of Tomcat > and here are the results. > > > Tomcat xalan lib in /WEB-INF/lib/ > ------ -------------------------- > 3.3.1 OK > 4.0.2 NOT OK > 4.0.3 NOT OK > 4.0.4 OK > > > The only way to make 4.0.2 and 4.0.3 aware of xalan libs is to have the > xalan jar files in "Bootstrap classes of my JVM" which is in > /usr/local/jdk1.3.1_02/jre/lib/ext. But having the libs in this > directory can effect other applications within the same container. How > do I make my Tomcat 4.0.2 and 4.0.3 use the xalan lib in my > /WEB-INF/lib/ directory? Is this a Tomcat config problem or a Xalan > config problem? > > Thanks > Stephen > > > > > -- > To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> > > > -- > To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
