Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
2.2.9
-
None
-
None
Description
Following a contract first approach, if I expose a WSDL which imports a XSD with a DOCTYPE declaration, for instance:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xs:schema PUBLIC "-//W3C//DTD XMLSCHEMA 200102//EN" "http://www.w3.org/2001/XMLSchema.dtd">
<!--
[...]
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" [...]>
then, when invoking the CXFServlet to show this XSD I get the following exception:
java.lang.NullPointerException
at com.sun.xml.internal.stream.writers.UTF8OutputStreamWriter.write(UTF8OutputStreamWriter.java:127)
at com.sun.xml.internal.stream.writers.XMLStreamWriterImpl.writeDTD(XMLStreamWriterImpl.java:722)
at org.apache.cxf.staxutils.StaxUtils.writeNode(StaxUtils.java:775)
at org.apache.cxf.staxutils.StaxUtils.writeDocument(StaxUtils.java:600)
at org.apache.cxf.staxutils.StaxUtils.writeDocument(StaxUtils.java:588)
at org.apache.cxf.staxutils.StaxUtils.writeNode(StaxUtils.java:762)
at org.apache.cxf.transport.http.WSDLQueryHandler.writeResponse(WSDLQueryHandler.java:230)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:162)
at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:142)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:179)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:108)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:159)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)
This is because org.apache.cxf.staxutils.StaxUtils.writeNode(Node, XMLStreamWriter, boolean) does the following for a Node of type DOCUMENT_TYPE_NODE:
try
{ writer.writeDTD(((DocumentType)n).getTextContent()); }catch (UnsupportedOperationException ex)
{ //can we ignore? DOM writers really don't allow this //as there isn't a way to write a DTD in dom }However, org.w3c.dom.Node.getTextContent() by contract returns NULL for a Node of type DOCUMENT_TYPE_NODE. This causes the NPE.