Docker容器内的Tomcat Web服务返回由NoSuchMethodError引起的HTTP 500

时间:2018-10-15 15:19:56

标签: java web-services docker tomcat

我试图调用在Docker容器内的Tomcat 9.0.12上运行的WebService。

我的Tomcat似乎配置正确,因为当我在没有Docker的情况下将WebService部署到其上时,我可以像这样https://localhost:8843/foo/services/foo?wsdl

如果我通过浏览器调用该服务,它将返回HTTP状态500,并且由于根本原因,我收到NoSuchMethodError

如果我尝试在Docker容器中运行服务时调用该服务,它将失败(请参见下面的异常),现在奇怪的是,当我调用https://localhost:8843/foo/services时,Tomcat将列出我的所有Web服务,包括其中的一个以上。

即使我查看我的应用程序日志文件,也没有异常等。该服务只是正常启动。

例外:

javax.servlet.ServletException: Servlet execution threw an exception
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

引起的原因:

 java.lang.NoSuchMethodError:org.codehaus.stax2.ri.EmptyIterator.getInstance()Lorg/codehaus/stax2/ri/EmptyIterator;
at com.ctc.wstx.sw.OutputElementBase.getPrefixes(OutputElementBase.java:358)
at org.apache.cxf.staxutils.StaxUtils.writeStartElement(StaxUtils.java:811)
at org.apache.cxf.staxutils.StaxUtils.copy(StaxUtils.java:758)
at org.apache.cxf.staxutils.StaxUtils.copy(StaxUtils.java:722)
at org.apache.cxf.staxutils.StaxUtils.copy(StaxUtils.java:648)
at org.apache.cxf.wsdl11.SchemaSerializer.writeXml(SchemaSerializer.java:58)
at org.apache.cxf.wsdl11.SchemaSerializer.marshall(SchemaSerializer.java:49)
at com.ibm.wsdl.xml.WSDLWriterImpl.printExtensibilityElements(WSDLWriterImpl.java:998)
at com.ibm.wsdl.xml.WSDLWriterImpl.printTypes(WSDLWriterImpl.java:882)
at com.ibm.wsdl.xml.WSDLWriterImpl.printDefinition(WSDLWriterImpl.java:131)
at com.ibm.wsdl.xml.WSDLWriterImpl.writeWSDL(WSDLWriterImpl.java:1073)
at com.ibm.wsdl.xml.WSDLWriterImpl.getDocument(WSDLWriterImpl.java:1038)
at org.apache.cxf.frontend.WSDLGetUtils.writeWSDLDocument(WSDLGetUtils.java:705)
at org.apache.cxf.frontend.WSDLGetUtils.getDocument(WSDLGetUtils.java:151)
at org.apache.cxf.frontend.WSDLGetInterceptor.getDocument(WSDLGetInterceptor.java:129)
at org.apache.cxf.frontend.WSDLGetInterceptor.handleMessage(WSDLGetInterceptor.java:77)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:267)
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160)
at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:216)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:301)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:225)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:276)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:607)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:770)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)

如果您需要更多信息,请评论并告诉我您需要什么!

1 个答案:

答案 0 :(得分:0)

通过添加以下依赖关系对其进行了修复:

<!-- https://mvnrepository.com/artifact/org.codehaus.woodstox/stax2-api -->
<dependency>
    <groupId>org.codehaus.woodstox</groupId>
    <artifactId>stax2-api</artifactId>
    <version>3.1.4</version>
</dependency>