On Aug 7, 2012, at 8:39 AM, Andrew Voumard <[email protected]> wrote:
> Hi,
>
> I am having a problem with the parsing of XML documents, using Xerces for
> Java 2.6.2. I am having the problem inside of a war file in Sun Application
> Server 8.2. It all runs on Windows XP SP2, under JRE 1.5.0_22. Updating to
> JRE 1.6 is not an option right now.
Such an ancient version of Xerces…. not sure if it will work.
Really, I have no idea what would cause this. I guess my first suggestion
would be to try just this app with a newer JDK and Xerces version and see if
it's still a problem. If so, it may be CXF. A test case would likely be
needed though.
Dan
>
> I have some code that validates XML documents against an XML Schema in some
> code that services web service requests - that code is deployed inside a war
> file. It was all previously working when I had been using Axis 1 (JAX-RPC)
> for web services. When I switched to CXF 2.6.2 and JAX-WS, the xs:include
> schemaLocation="file" directives began to fail. All XML Schema files are in
> the local filesystem. Instead of looking for include files relative to the
> directory where the including XML Schema file exists (as it had been doing),
> xerces is now looking for the include file in a parent directory 2 levels up.
>
> I tried to register an EntityResolver against the DocumentBuilder, but it was
> nnever called back:
>
> Document doc = null;
>
> System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
>
> "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
>
> final DocumentBuilderFactory factory = DocumentBuilderFactory
> .newInstance();
> factory.setNamespaceAware(true);
> factory.setValidating(true);
> factory.setAttribute(
>
> "http://java.sun.com/xml/jaxp/properties/schemaLanguage",
> "http://www.w3.org/2001/XMLSchema");
> factory.setAttribute(
>
> "http://java.sun.com/xml/jaxp/properties/schemaSource",
> xmlSchemaUrl);
>
> final DocumentBuilder builder = factory.newDocumentBuilder();
>
> builder.setEntityResolver(XmlSchemaEntityResolver.getSingleInstance());
>
> final InputSource is = new InputSource(new
> StringReader(xmlDoc));
> doc = builder.parse(is);
> // parse fails because includes fail ...
>
> Then I read
>
> http://xerces-j-users.markmail.org/message/2ze2qcwmmx3t253g?q=cxf
>
> which said CXF might not be configuring JAXB correctly - it was an old issue,
> but I thought it might be of some help to note here.
>
> If I hardcode the absolute path, or modify the relative path, everything
> works ok, but I have hundreds of schema files to work with, and other
> applications use them as well, so changing them is not really an option.
>
> A sample stack backtrace is shown below. It is failing because the 'Header'
> element is unknown, and that is because the include that loads the XML Schema
> file containing the 'Header' element definition failed to get included. Note
> that I had to recompile xerces 2.6.2 with debug on, to get the line numbers
> shown below.
>
> I have spent quite a bit of time trying to resolve this with no luck. Does
> anyone have any ideas on what I need to configure or code to get the XML
> Schema includes to look for the file specified by the schemaLocation in a
> directory relative to the XML Schema file containing the actual include
> directive ?
>
> Thanks
> Andrew
>
>
> [#|2012-08-07T15:52:07.392+1000|INFO|sun-appserver-pe8.2|javax.enterprise.system.stream.out|_ThreadID=13;|2012-08-07
> 15:52:07,392 [httpWorkerThread-8080-2] DEBUG com.company.utils.xml.XmlHelper
> -
> Stack Trace :
> org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was
> found starting with element 'Header'. One of '{"":GetDetails}' is expected.
> at
> org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
> at
> org.apache.xerces.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:172)
> at
> org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:380)
> at
> org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:314)
> at
> org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:410)
> at
> org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3114)
> at
> org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1758)
> at
> org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:686)
> at
> org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:320)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1534)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:338)
> at
> org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:828)
> at
> org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:758)
> at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:148)
> at org.apache.xerces.parsers.DOMParser.parse(DOMParser.java:248)
> at
> org.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:215)
> at com.company.utils.xml.XmlHelper.validateSchema(XmlHelper.java:98)
> at com.company.ws.MyServiceImpl.GetDetails(MyServiceImpl.java:40)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:592)
> at
> org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180)
> at
> org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
> at
> org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.invoke(AbstractJAXWSMethodInvoker.java:178)
> at org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:64)
> at
> org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:75)
> at
> org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
> at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:417)
> at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:269)
> at java.util.concurrent.FutureTask.run(FutureTask.java:123)
> at
> org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
> at
> org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:107)
> at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
> at
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:122)
> at
> org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:211)
> at
> org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:213)
> at
> org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:193)
> at
> org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:129)
> at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:187)
> at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:110)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:767)
> at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:166)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:592)
> at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
> at java.security.AccessController.doPrivileged(Native Method)
> at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
> at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
> at
> org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:257)
> at
> org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
> at
> org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161)
> at java.security.AccessController.doPrivileged(Native Method)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:263)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
> at
> org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:225)
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:173)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
> at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:132)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:933)
> at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:189)
> at
> com.sun.enterprise.web.connector.grizzly.ProcessorTask.doProcess(ProcessorTask.java:604)
> at
> com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:475)
> at
> com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:371)
> at
> com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:264)
> at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:281)
> at
> com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:83)
> |#]
>
>
--
Daniel Kulp
[email protected] - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com