tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Arnaud Héritier <aherit...@sopragroup.com>
Subject RE: the classloader doesn't like XML in TC 3.2.3 and TC 4.0
Date Wed, 21 Nov 2001 11:07:51 GMT
Hello.

With some documentations about Tomcat, Xalan, Xerces, Crimson and the 
mailing list archive, I finally found what's happenned.

The problem is that Jasper (the JSP compiler) can (and should) see my 
webapp classloader to compile JSPs files.
So by default Jasper use the crimson XML parser.
In the Crimson Jar there're 2 files in the META-INF/services :
javax.xml.parsers.DocumentBuilderFactory with the value 
org.apache.crimson.jaxp.DocumentBuilderFactoryImpl
javax.xml.parsers.SAXParserFactory with the value 
org.apache.crimson.jaxp.SAXParserFactoryImpl
This two files are used to configure the parser and to say it which class 
to use.
But when I use Xalan and so Xerces by default the classloader load the 
xerces Jar file which defines its own services files with
javax.xml.parsers.DocumentBuilderFactory with the value 
org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
javax.xml.parsers.SAXParserFactory with the value 
org.apache.xerces.jaxp.SAXParserFactoryImpl
This System properties are then replaced. There's a ClassCastException 
between the class org.apache.xerces.jaxp.DocumentBuilderFactoryImpl

and the class org.apache.crimson.jaxp.DocumentBuilderFactoryImpl


To resolve this problem there are several solutions.

1) Use xerces in tomcat instead of crimson as XML Parser. See the paragraph 
Tomcat 4 and XML Parsers in the Class Loader Documentation 
(http://jakarta.apache.org/tomcat/tomcat-4.0-doc/class-loader-howto.html)
2) Use crimson in my webapp instead xerces. I replaced the xerces.jar by 
the crimson.jar and jaxp.jar.
This two solutions are working so I hope that it will help some of you.

Arnaud H

> -----Message d'origine-----
> De:	Arnaud Héritier [SMTP:aheritier@sopragroup.com]
> Date:	mardi 20 novembre 2001 17:59
> À:	Tomcat Users List (Adresse de messagerie)
> Objet:	the classloader doesn't like XML in TC 3.2.3 and TC 4.0
>
> Snifffff, I'm in despair :-)
>
> I'm developping a web application with the Struts Framework. All worked
> correctly until I need to develop a new servlet used to transform XML
> Documents in HTML with Xalan.
> I used xerces with Struts, and all was good.
> But now I added xalan (xalan.jar,xml-apis.jar, and replace the 
xerces.jar)
> from the xalan J2 D13 distribution in the lib directory of my web
> application.
> So from now after each time when I access to my Xalan Servlet I can't
> access to the JSPs.
> Jasper give me this error :
>
> java.lang.ClassCastException:
> org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
> 	at
> javax.xml.parsers.DocumentBuilderFactory.newInstance(DocumentBuilderFact 
> ory.java:116)
> 	at
> 
org.apache.jasper.parser.ParserUtils.parseXMLDocument(ParserUtils.java:183)
> 	at
> org.apache.jasper.compiler.TagLibraryInfoImpl.parseTLD(TagLibraryInfoImp 
> l.java:278)
> 	at
> 
org.apache.jasper.compiler.TagLibraryInfoImpl.(TagLibraryInfoImpl.java:219)
> 	at org.apache.jasper.compiler.JspParseEventListener.processTaglibDirect 
> ive(JspParseEventListener.java:1150)
> 	at
> org.apache.jasper.compiler.JspParseEventListener.handleDirective(JspPars 
> eEventListener.java:755)
> 	at
> org.apache.jasper.compiler.DelegatingListener.handleDirective(Delegating 
> Listener.java:121)
> 	at org.apache.jasper.compiler.Parser$Directive.accept(Parser.java:243)
> 	at org.apache.jasper.compiler.Parser.parse(Parser.java:1132)
> 	at org.apache.jasper.compiler.Parser.parse(Parser.java:1091)
> 	at org.apache.jasper.compiler.Parser.parse(Parser.java:1087)
> 	at
> org.apache.jasper.compiler.ParserController.parse(ParserController.java: 
> 213)
> 	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:210)
> 	at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:543)
> 	at
> org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(J 
> spServlet.java:176)
> 	at
> org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServle 
> t.java:188)
> 	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java: 
> 381)
> 	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:1264)
> 	at
> org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatc 
> her.java:672)
> 	at
> org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDisp 
> atcher.java:430)
> 	at
> org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispat 
> cher.java:354)
> 	at
> org.apache.struts.action.ActionServlet.processActionForward(ActionServle 
> t.java:1758)
> 	at 
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1595)
> 	at
> com.sopra.projet.aladin.pfe.stock.gui.servlet.PFEActionServlet.process(P 
> FEActionServlet.java:137)
> 	at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:491)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:1125)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:1264)
> 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(App 
> licationFilterChain.java:247)
> 	at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt 
> erChain.java:193)
> 	at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv 
> e.java:243)
> 	at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.ja 
> va:566)
> 	at
> 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> 	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> 	at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValv 
> e.java:215)
> 	at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.ja 
> va:566)
> 	at
> 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> 	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> 	at
> org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2  
366)
> 	at al for the 
sole
> use of the intended recipient. Any review or distribution by others is
> strictly prohibited. If you are not the intended recipient, please 
contact
> the sender and delete all copies.
>
>
>
> --
> To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
> For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
> Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message