Tomcat 7.0 部署Webservices发生IOException和XMLStreamException异常

      最近学习Webservices,在Tomcat 7.0 使用JAX-WS部署一个两数相加的Webservices。启动服务后打开http://localhost:8089/wsdlwtest_01/addnumbers,可以看到:

服务名: {http://std.hjs.com/ws/}AddNumbersService 
端口名: {http://std.hjs.com/ws/}AddNumbersPort 
 地址: http://localhost:8089/wtest_01/addnumbers 
WSDL: http://localhost:8089/wtest_01/addnumbers?wsdl 
实现类: com.hjs.std.ws.AddNumbersImpl 

等服务内容.

     但当打开http://localhost:8089/wtest_01/addnumbers?wsdl时,却报以下错误:

java.io.IOException: Trying to writeEND_DOCUMENT when document has no root (ie. trying to output empty document).

atcom.sun.xml.ws.server.SDDocumentImpl.writeTo(SDDocumentImpl.java:299)

       atcom.sun.xml.ws.transport.http.HttpAdapter.publishWSDL(HttpAdapter.java:931)

       atcom.sun.xml.ws.transport.http.HttpAdapter.handleGet(HttpAdapter.java:440)

       atcom.sun.xml.ws.transport.http.servlet.ServletAdapter.invokeAsync(ServletAdapter.java:193)

       atcom.sun.xml.ws.transport.http.servlet.WSServletDelegate.doGet(WSServletDelegate.java:161)

       atcom.sun.xml.ws.transport.http.servlet.WSServlet.doGet(WSServlet.java:89)

       atjavax.servlet.http.HttpServlet.service(HttpServlet.java:621)

       atjavax.servlet.http.HttpServlet.service(HttpServlet.java:728)

       atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)

       atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)

       atorg.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)

       atorg.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)

       atorg.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)

       atorg.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)

       atorg.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)

       atorg.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)

       atorg.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)

       atorg.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)

       atorg.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)

       atorg.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)

       atorg.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)

       atjava.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

       atjava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

       atjava.lang.Thread.run(Thread.java:724)

Caused by:javax.xml.stream.XMLStreamException: Trying to write END_DOCUMENT when documenthas no root (ie. trying to output empty document).

       atcom.ctc.wstx.sw.BaseStreamWriter.throwOutputError(BaseStreamWriter.java:1524)

       atcom.ctc.wstx.sw.BaseStreamWriter.reportNwfStructure(BaseStreamWriter.java:1553)

       atcom.ctc.wstx.sw.BaseStreamWriter._finishDocument(BaseStreamWriter.java:1379)

       atcom.ctc.wstx.sw.BaseStreamWriter.close(BaseStreamWriter.java:249)

       atcom.sun.xml.ws.util.xml.XMLStreamWriterFilter.close(XMLStreamWriterFilter.java:67)

       atcom.sun.xml.ws.server.SDDocumentImpl.writeTo(SDDocumentImpl.java:297)

       ... 23 more

应该是无法写wsdl文件的根元素,网上找了n遍,没有得到有用的答案。想了许多,应该是各个jar包有冲突、不兼容、版本等原因。

后来试验,应该属于jax-ws rt 版本的问题,用2.2.10-b140803.1500时会出现上述情况,改为2.2.8就没问题了,可能是前者是beta版本吧!

你可能感兴趣的:(java)