[jdom-interest] Tomcat and JDOM compatability

Dennis Sosnoski dms at sosnoski.com
Thu Nov 8 16:07:34 PST 2001


Hi Walter,

I've had problems using Tomcat, too. In my case I wanted to use the 
Crimson parser. I think the root problem may be the same, though.

XMLReaderFactory.createXMLReader() appears to sometimes get confused 
about which classloader to use when running under Tomcat. I was able to 
get around the problem with using Crimson by subclassing SAXBuilder and 
overriding the createParser() method to just return an instance of the 
parser I wanted. The same approach would probably work for you with 
Xerces. You can see my email on this at 
http://lists.denveronline.net/lists/jdom-interest/2001-November/008721.html 
if you're interested.

  - Dennis

Walter Slotboom wrote:

>I apologize if this appears twice, original was sent from different
>email address so system thinks I am non-member.
>
>NT 4.0 sp6
>Tomcat v4.01
>JDOM Beta 7
>
>I recently developed a standalone program that employed JDOM for its
>XML needs, and it worked without problem (great work by all involved in
>JDOM development).  However, the need has arisen for my program to be
>used in a Servlet / JSP context using Tomcat.  It appears that there
>exists an incompatability between the two, or some configuration
>concerns.  My current assumption is that their xerces.jar have some
>conflicts (I have tried using the xerces.jar provided with both JDOM
>and Tomcat with the same results) .
>
>Is there a recommended Tomcat / JDOM version mixture?
>Is there a xerces.jar that works with both?
>What exactly is this exception indicating?
>Any other ideas?
>
>The following code will fail regardless of whether XMLFile is a string
>containing the full path or a File object.
>
>SAXBuilder builder = new SAXBuilder();
>Document doc = builder.build(XMLFile);
>
>The exception returned is the following.
>
>java.lang.ClassCastException: org.apache.xerces.parsers.SAXParser
>        at
>org.xml.sax.helpers.XMLReaderFactory.createXMLReader(XMLReaderFactory.java:128)
>        at org.jdom.input.SAXBuilder.createParser(SAXBuilder.java:411)
>        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:283)
>        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:682)
>        at
>com.tpt.test.mimic.client.ClientReader.getClients(ClientReader.java:95)
>        at
>com.tpt.test.mimic.client.ClientFactory.initialize(ClientFactory.java:73)
>        at
>com.tpt.test.mimic.client.ClientFactory.<init>(ClientFactory.java:26)
>        at
>com.tpt.test.mimic.client.ClientFactory.getInstance(ClientFactory.java:88)
>        at
>com.tpt.test.mimic.client.ClientService.getClientNames(ClientService.java:53)
>        at com.tpt.test.MimicServlet.getItems(MimicServlet.java:63)
>        at org.apache.jsp.mimic$jsp._jspService(mimic$jsp.java:88)
>        at
>org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>        at
>org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:202)
>        at
>org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
>        at
>org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>        at
>org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
>        at
>org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
>        at
>org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
>        at
>org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java: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(StandardContextValve.java:201)
>        at
>org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java: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:2344)
>        at
>org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
>        at
>org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
>        at
>org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
>        at
>org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
>        at
>org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
>        at
>org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
>        at
>org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462)
>        at
>org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
>        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.StandardEngineValve.invoke(StandardEngineValve.java:163)
>        at
>org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java: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.connector.http.HttpProcessor.process(HttpProcessor.java:1011)
>        at
>org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1106)
>        at java.lang.Thread.run(Thread.java:484)
>
>Thanks for any assistance...
>
>--
>Walter
>
>
>=====
>--
>Walter Slotboom
>walterslotboom at yahoo.com
>512-331-4732
>
>__________________________________________________
>Do You Yahoo!?
>Find a job, post your resume.
>http://careers.yahoo.com
>_______________________________________________
>To control your jdom-interest membership:
>http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
>
>





More information about the jdom-interest mailing list