[jdom-interest] JDOM8,XERCES2.3,TOMCAT4.0 Schema Validation - Class Cast Exceptio
n Unkown Source Error
Bajaj, Shailesh
Shailesh.Bajaj at atosorigin.com
Tue Apr 8 02:27:57 PDT 2003
Hi All,
I wanted to do schema validation. My XML document would be in the form of an
String.
It works fine when I wun standalone but fails on tomcat.
I am getting Class Cast Exception
Caused by: java.lang.ClassCastException
at org.apache.xerces.impl.xs.XMLSchemaValidator.reset(Unknown
Source)
at org.apache.xerces.parsers.BasicParserConfiguration.reset(Unknown
Source)
at org.apache.xerces.parsers.DTDConfiguration.reset(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:354)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:740)
at
com.wpp_ai.biz.bizsvc.SchemaValidator.entitySchemaValidate(SchemaValidator.j
ava:138)
Has anybody come across something like this earlier. TIA
My code looks like this.
SAXBuilder builder = null;
Document document;
builder = new SAXBuilder("org.apache.xerces.parsers.SAXParser");
File f = new File(ServletBean.getFileRealPath(strEntityFile));
StringReader sr = new StringReader(xmlData);
BestSAXChecker oerrorhandler = new BestSAXChecker();
builder.setProperty(
"http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation"
,
f.toURI());
builder.setValidation(true);
builder.setErrorHandler(oerrorhandler);
// turn on schema support
builder.setFeature(
"http://apache.org/xml/features/validation/schema",
true);
builder.setFeature(
"http://apache.org/xml/features/validation/schema-full-checking",
true);
try {
document = builder.build(sr); }
Class BestSAXChecker implements ErrorHandler and the three methods.
It fails on the line builder.build(sr)
The error trace is somthing like this
Starting service Tomcat-Standalone
Apache Tomcat/4.0
org.jdom.JDOMException: Error in building
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:373)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:740)
at
com.wpp_ai.biz.bizsvc.SchemaValidator.entitySchemaValidate(SchemaVali
dator.java:138)
at
com.wpp_ai.biz.bizsvc.SchemaValidator.validateAgainstSchema(SchemaVal
idator.java:53)
at
com.wpp_ai.infra.axissvc.AIConfigurationServlet.testschemavalida(AICo
nfigurationServlet.java:88)
at
com.wpp_ai.infra.axissvc.AIConfigurationServlet.init(AIConfigurationS
ervlet.java:44)
at javax.servlet.GenericServlet.init(GenericServlet.java:258)
at org.apache.catalina.core.StandardWrapper.load(Unknown Source)
at org.apache.catalina.core.StandardContext.loadOnStartup(Unknown
Source
)
at org.apache.catalina.core.StandardContext.start(Unknown Source)
at org.apache.catalina.core.ContainerBase.addChild(Unknown Source)
at org.apache.catalina.core.StandardHost.addChild(Unknown Source)
at org.apache.catalina.core.StandardHost.install(Unknown Source)
at org.apache.catalina.startup.HostConfig.deployApps(Unknown Source)
at org.apache.catalina.startup.HostConfig.start(Unknown Source)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(Unknown
Source)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Unknown
Source)
at org.apache.catalina.core.ContainerBase.start(Unknown Source)
at org.apache.catalina.core.ContainerBase.start(Unknown Source)
at org.apache.catalina.core.StandardEngine.start(Unknown Source)
at org.apache.catalina.core.StandardService.start(Unknown Source)
at org.apache.catalina.core.StandardServer.start(Unknown Source)
at org.apache.catalina.startup.Catalina.start(Unknown Source)
at org.apache.catalina.startup.Catalina.execute(Unknown Source)
at org.apache.catalina.startup.Catalina.process(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.main(Unknown Source)
Caused by: java.lang.ClassCastException
at org.apache.xerces.impl.xs.XMLSchemaValidator.reset(Unknown
Source)
at org.apache.xerces.parsers.BasicParserConfiguration.reset(Unknown
Sour
ce)
at org.apache.xerces.parsers.DTDConfiguration.reset(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:354)
... 29 more
Caused by: java.lang.ClassCastException
at org.apache.xerces.impl.xs.XMLSchemaValidator.reset(Unknown
Source)
at org.apache.xerces.parsers.BasicParserConfiguration.reset(Unknown
Sour
ce)
at org.apache.xerces.parsers.DTDConfiguration.reset(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:354)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:740)
at
com.wpp_ai.biz.bizsvc.SchemaValidator.entitySchemaValidate(SchemaVali
dator.java:138)
at
com.wpp_ai.biz.bizsvc.SchemaValidator.validateAgainstSchema(SchemaVal
idator.java:53)
at
com.wpp_ai.infra.axissvc.AIConfigurationServlet.testschemavalida(AICo
nfigurationServlet.java:88)
at
com.wpp_ai.infra.axissvc.AIConfigurationServlet.init(AIConfigurationS
ervlet.java:44)
at javax.servlet.GenericServlet.init(GenericServlet.java:258)
at org.apache.catalina.core.StandardWrapper.load(Unknown Source)
at org.apache.catalina.core.StandardContext.loadOnStartup(Unknown
Source
)
at org.apache.catalina.core.StandardContext.start(Unknown Source)
at org.apache.catalina.core.ContainerBase.addChild(Unknown Source)
at org.apache.catalina.core.StandardHost.addChild(Unknown Source)
at org.apache.catalina.core.StandardHost.install(Unknown Source)
at org.apache.catalina.startup.HostConfig.deployApps(Unknown Source)
at org.apache.catalina.startup.HostConfig.start(Unknown Source)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(Unknown
Source)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Unknown
Source)
at org.apache.catalina.core.ContainerBase.start(Unknown Source)
at org.apache.catalina.core.ContainerBase.start(Unknown Source)
at org.apache.catalina.core.StandardEngine.start(Unknown Source)
at org.apache.catalina.core.StandardService.start(Unknown Source)
at org.apache.catalina.core.StandardServer.start(Unknown Source)
at org.apache.catalina.startup.Catalina.start(Unknown Source)
at org.apache.catalina.startup.Catalina.execute(Unknown Source)
at org.apache.catalina.startup.Catalina.process(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.main(Unknown Source)
Caused by: java.lang.ClassCastException
at org.apache.xerces.impl.xs.XMLSchemaValidator.reset(Unknown
Source)
at org.apache.xerces.parsers.BasicParserConfiguration.reset(Unknown
Sour
ce)
at org.apache.xerces.parsers.DTDConfiguration.reset(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:354)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:740)
at
com.wpp_ai.biz.bizsvc.SchemaValidator.entitySchemaValidate(SchemaVali
dator.java:138)
at
com.wpp_ai.biz.bizsvc.SchemaValidator.validateAgainstSchema(SchemaVal
idator.java:53)
at
com.wpp_ai.infra.axissvc.AIConfigurationServlet.testschemavalida(AICo
nfigurationServlet.java:88)
at
com.wpp_ai.infra.axissvc.AIConfigurationServlet.init(AIConfigurationS
ervlet.java:44)
at javax.servlet.GenericServlet.init(GenericServlet.java:258)
at org.apache.catalina.core.StandardWrapper.load(Unknown Source)
at org.apache.catalina.core.StandardContext.loadOnStartup(Unknown
Source
)
at org.apache.catalina.core.StandardContext.start(Unknown Source)
at org.apache.catalina.core.ContainerBase.addChild(Unknown Source)
at org.apache.catalina.core.StandardHost.addChild(Unknown Source)
at org.apache.catalina.core.StandardHost.install(Unknown Source)
at org.apache.catalina.startup.HostConfig.deployApps(Unknown Source)
at org.apache.catalina.startup.HostConfig.start(Unknown Source)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(Unknown
Source)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Unknown
Source)
at org.apache.catalina.core.ContainerBase.start(Unknown Source)
at org.apache.catalina.core.ContainerBase.start(Unknown Source)
at org.apache.catalina.core.StandardEngine.start(Unknown Source)
at org.apache.catalina.core.StandardService.start(Unknown Source)
at org.apache.catalina.core.StandardServer.start(Unknown Source)
at org.apache.catalina.startup.Catalina.start(Unknown Source)
at org.apache.catalina.startup.Catalina.execute(Unknown Source)
at org.apache.catalina.startup.Catalina.process(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.main(Unknown Source)
Starting service Tomcat-Apache
Apache Tomcat/4.0
With Regards ,
- Shailesh
More information about the jdom-interest
mailing list