Bug 4330 - ClassCastException with DocumentBuilderFactoryImpl
Summary: ClassCastException with DocumentBuilderFactoryImpl
Status: RESOLVED WORKSFORME
Alias: None
Product: Tomcat 4
Classification: Unclassified
Component: Jasper (show other bugs)
Version: 4.0.1 Final
Hardware: PC All
: P3 blocker (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-10-22 05:43 UTC by Joel P. Worrall
Modified: 2005-03-20 17:06 UTC (History)
0 users



Attachments
server.xml of offending Tomcat install (1.53 KB, text/plain)
2001-10-23 04:18 UTC, Joel P. Worrall
Details
Offending Server.xml (15.77 KB, text/plain)
2002-01-03 13:30 UTC, Milind Nirgun
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joel P. Worrall 2001-10-22 05:43:18 UTC
I was starting up the Tomcat 4.0 servlet engine, running against JDK 1.4 and 
received the following error when attempting to start the engine.  I'm willing 
to believe this is just a library issue on my part, but I'm not an idiot and 
have been hunting it down for 2 days now.  I even rebuilt the XErces2 jar under 
my running 1.4 environment (by downloading the source and running Ant against 
my JAVA_HOME.  

I have posted several questions to the tomcat users list with no reponses, and 
searched through the archives for similar issues with no success.  This leads 
me to believe it may in fact be a bug.  Please contact for more info if 
necessary.

The Stacktrace follows....

javax.servlet.ServletException: Servlet.init() for servlet jsp threw exception
	at org.apache.catalina.core.StandardWrapper.load
(StandardWrapper.java:871)
	at org.apache.catalina.core.StandardContext.loadOnStartup
(StandardContext.java:3267)
	at org.apache.catalina.core.StandardContext.start
(StandardContext.java:3384)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
	at org.apache.catalina.core.StandardHost.start(StandardHost.java:612)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
	at org.apache.catalina.core.StandardEngine.start
(StandardEngine.java:307)
	at org.apache.catalina.core.StandardService.start
(StandardService.java:388)
	at org.apache.catalina.core.StandardServer.start
(StandardServer.java:505)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:776)
	at org.apache.catalina.startup.Catalina.execute(Catalina.java:681)
	at org.apache.catalina.startup.Catalina.process(Catalina.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:42)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:28)
	at java.lang.reflect.Method.invoke(Method.java:313)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:243)
----- Root Cause -----
java.lang.ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
	at javax.xml.parsers.DocumentBuilderFactory.newInstance
(DocumentBuilderFactory.java:103)
	at org.apache.jasper.parser.ParserUtils.parseXMLDocument
(ParserUtils.java:183)
	at org.apache.jasper.compiler.TldLocationsCache.processWebDotXml
(TldLocationsCache.java:165)
	at org.apache.jasper.compiler.TldLocationsCache.<init>
(TldLocationsCache.java:138)
	at org.apache.jasper.EmbededServletOptions.<init>
(EmbededServletOptions.java:324)
	at org.apache.jasper.servlet.JspServlet.init(JspServlet.java:266)
	at org.apache.catalina.core.StandardWrapper.load
(StandardWrapper.java:852)
	at org.apache.catalina.core.StandardContext.loadOnStartup
(StandardContext.java:3267)
	at org.apache.catalina.core.StandardContext.start
(StandardContext.java:3384)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
	at org.apache.catalina.core.StandardHost.start(StandardHost.java:612)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
	at org.apache.catalina.core.StandardEngine.start
(StandardEngine.java:307)
	at org.apache.catalina.core.StandardService.start
(StandardService.java:388)
	at org.apache.catalina.core.StandardServer.start
(StandardServer.java:505)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:776)
	at org.apache.catalina.startup.Catalina.execute(Catalina.java:681)
	at org.apache.catalina.startup.Catalina.process(Catalina.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:42)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:28)
	at java.lang.reflect.Method.invoke(Method.java:313)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:243)
Comment 1 Kin-Man Chung 2001-10-22 14:45:46 UTC
This is hardly a jasper problem.  xerces.jar is part of Tomcat 4.0.1 Final
distriubution; but make sure you don't have any incompatible XML parser that got
loaded instead.  Does JDK 1.4 come with one?  Try using JDK 1.3 to see if it
change anything.

In any case, please give me a test case that I can run with JDK1.4.  Thanks.
Comment 2 Joel P. Worrall 2001-10-23 04:18:03 UTC
Created attachment 707 [details]
server.xml of offending Tomcat install
Comment 3 Joel P. Worrall 2001-10-23 04:23:18 UTC
I scanned the jars in my classpath and the only jar that has a 
org.apache.xerces.jaxp.DocumentBuilderFactoryImpl is the xerces.jar that I 
built under my 1.4 environment.  And the only jar that has a 
javax.xml.parsers.DocumentBuilderFactory is the rt.jar under my 1.4 
environment.  The engine is failing on startup, so there's no real test case 
except the following:

install 4.0.1
use the server.xml I provided on the earlier post.
watch it fail

I am happy to hear back that this is me being a dope, but please give me a clue 
why.
Comment 4 Kin-Man Chung 2001-10-24 18:51:37 UTC
I ran Tomcat 4.0 with JDK 1.4.0 beta without any problem.  Your server.xml looks
fine.  You don't need to build your own xerces to run tomcat.  You also don't
nee to define CLASSPATH.
Comment 5 Martijn Koster 2001-11-29 06:37:36 UTC
I encountered the same problem today, when I set up a fresh build
environment, including xerces-1_4_4. Using xerces 1_4_3 instead
worked for me. In both cases I used the 1.3 JDK, not 1.4. The
Tomcat source tree was fresh from CVS today.

Joel, were you using xerces-1_4_4 as well by any chance?

I have not looked further into what the root cause or right fix is.
Comment 6 Milind Nirgun 2002-01-03 13:30:29 UTC
Created attachment 975 [details]
Offending Server.xml
Comment 7 Milind Nirgun 2002-01-03 13:34:24 UTC
I encountered the same problem with tomcat4.0.1/Win2k/jdk 1.4 beta-3 and after 
2 days of testing, I have found that whenever I add a new JSP page in any new 
context I created it throws up with the following exceptions. The same JSP 
works if put in the "examples" context. I found that changing the jdk to 1.3 
solved the problem for me.
I have also attached my server.xml file.

Stacktrace follows:

javax.servlet.ServletException: Servlet.init() for servlet jsp threw exception
	at org.apache.catalina.core.StandardWrapper.load
(StandardWrapper.java:871)
	at org.apache.catalina.core.StandardWrapper.allocate
(StandardWrapper.java:615)
	at org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:214)
	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.valves.CertificatesValve.invoke
(CertificatesValve.java:246)
	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.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.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:539)
root cause java.lang.ClassCastException: 
org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
	at javax.xml.parsers.DocumentBuilderFactory.newInstance
(DocumentBuilderFactory.java:103)
	at org.apache.jasper.parser.ParserUtils.parseXMLDocument
(ParserUtils.java:183)
	at org.apache.jasper.compiler.TldLocationsCache.processWebDotXml
(TldLocationsCache.java:165)
	at org.apache.jasper.compiler.TldLocationsCache.<init>
(TldLocationsCache.java:138)
	at org.apache.jasper.EmbededServletOptions.<init>
(EmbededServletOptions.java:324)
	at org.apache.jasper.servlet.JspServlet.init(JspServlet.java:266)
	at org.apache.catalina.core.StandardWrapper.load
(StandardWrapper.java:852)
	at org.apache.catalina.core.StandardWrapper.allocate
(StandardWrapper.java:615)
	at org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:214)
	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.valves.CertificatesValve.invoke
(CertificatesValve.java:246)
	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.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.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:539)

Comment 8 Kin-Man Chung 2002-01-04 18:26:50 UTC
I routinely use j2sdk1.4.0 with tomcat and never run into this problem.  I am
closing this as WORKSFORME.  If you can attach a test case in the form of a .war
that I can drop into tomcat that shows this problem, please reopen this bug
again.  Thanks.