代码之家  ›  专栏  ›  技术社区  ›  Sammitch

两个运行相同服务的相同主机,但其中一个无法解析WSDL

  •  0
  • Sammitch  · 技术社区  · 4 年前

    我们的情况如下:我们通过自动化提供新的k8s集群,并通过自动化构建/部署我们的微服务。到目前为止,我已经部署了几个pre-prod集群,没有任何问题,但是现在我们进入了集成测试环境,现在有一个服务容器正在做一些事情 非常

    在Host1上运行的容器会像往常一样启动:

    2020-12-10 00:46:39,717 INFO  [main] company.Api (Api.java:20) - Running against https://sandboxapi2.example.com/3.0/exampleApi.asmx with user company_example_api_user1
    2020-12-10 00:46:39,864 DEBUG [main] resource.DefaultResourceManager (DefaultResourceManager.java:110) - resolving resource <org.apache.cxf.wsdl11.WSDLManagerImpl/bus> type <interface org.apache.cxf.Bus>
    2020-12-10 00:46:39,865 DEBUG [main] resource.DefaultResourceManager (DefaultResourceManager.java:110) - resolving resource <null> type <interface org.apache.cxf.Bus>
    2020-12-10 00:46:40,066 TRACE [main] helpers.DOMUtils (DOMUtils.java:83) - can't load class com.sun.xml.messaging.saaj.soap.SOAPDocumentImpl
    2020-12-10 00:46:40,457 DEBUG [main] jaxws.ServiceImpl (ServiceImpl.java:430) - creating port for portName
    2020-12-10 00:46:40,458 DEBUG [main] jaxws.ServiceImpl (ServiceImpl.java:431) - endpoint reference:
    2020-12-10 00:46:40,458 DEBUG [main] jaxws.ServiceImpl (ServiceImpl.java:432) - endpoint interface:
    2020-12-10 00:46:40,513 INFO  [main] factory.ReflectionServiceFactoryBean (ReflectionServiceFactoryBean.java:391) - Creating Service {http://api.example.com/}exampleApi from WSDL: jar:file:/lib/exampleclient-1.0-SNAPSHOT.jar!/example.wsdl
    ...
    

    但是,在Host2上运行的容器在解析绑定到容器映像中的WSDL时遇到致命错误:

    2020-12-10 00:48:06,865 INFO  [main] company.Api (Api.java:20) - Running against https://sandboxapi2.example.com/3.0/exampleApi.asmx with user company_example_api_user1
    2020-12-10 00:48:07,036 DEBUG [main] resource.DefaultResourceManager (DefaultResourceManager.java:110) - resolving resource <org.apache.cxf.wsdl11.WSDLManagerImpl/bus> type <interface org.apache.cxf.Bus>
    2020-12-10 00:48:07,037 DEBUG [main] resource.DefaultResourceManager (DefaultResourceManager.java:110) - resolving resource <null> type <interface org.apache.cxf.Bus>
    2020-12-10 00:48:07,231 TRACE [main] helpers.DOMUtils (DOMUtils.java:83) - can't load class com.sun.xml.messaging.saaj.soap.SOAPDocumentImpl
    [Fatal Error] :1:1: Content is not allowed in prolog.
    

    这两个容器作为POD部署在同一个k8s部署中,只是部署到集群中的不同主机。

    我尝试/验证过的事情:

    • 每个构建对图像进行唯一标记,标记从不修改,容器规范使用适当的特定标记,例如: company/example:master.99-6920514A ,因此我们在每台主机上获得的图像肯定是相同的。
    • 没有文件或卷装入容器,所有配置都通过环境变量提供。
    • 重新部署与服务关联的所有k8s资源:部署、configmaps等。
    • 从机器上擦除图像并重新拖动。
    • 验证两台主机上启动的容器的类路径匹配中所有内容的校验和。
    • 提取WSDL并验证文件前缀中没有BOM或其他数据。
      # jar xf /lib/exampleclient-1.0-SNAPSHOT.jar example.wsdl
      # head -n 1 example.wsdl | hexdump -C
      00000000  3c 3f 78 6d 6c 20 76 65  72 73 69 6f 6e 3d 22 31  |<?xml version="1|
      00000010  2e 30 22 20 65 6e 63 6f  64 69 6e 67 3d 22 75 74  |.0" encoding="ut|
      00000020  66 2d 38 22 3f 3e 0d 0a                           |f-8"?>..|
      
    • xmmlint example.wsdl 没有人抱怨。
    • tcpdump容器以验证它是否正在运行 任何

    我们都在绞尽脑汁想弄清楚这里发生了什么。有人知道这可能是什么原因吗,或者我们可以进一步调查什么?

    完整堆栈跟踪:

    Exception in thread "main" javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
        at org.apache.cxf.jaxws.ServiceImpl.initialize(ServiceImpl.java:163)
        at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:129)
        at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:82)
        at javax.xml.ws.Service.<init>(Service.java:77)
        at com.example.api.exampleApi.<init>(exampleApi.java:49)
        at com.company.Api.<init>(Api.java:27)
        at com.company.payout.Main.main(Main.java:43)
    Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
        at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:87)
        at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:218)
        at org.apache.cxf.jaxws.ServiceImpl.initialize(ServiceImpl.java:161)
        ... 6 more
    Caused by: javax.wsdl.WSDLException: WSDLException (at /wsdl:definitions/wsdl:types/s:schema[1]): faultCode=PARSER_ERROR: Problem parsing 'file:/'.: org.xml.sax.SAXParseException: Content is not allowed in prolog.
        at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(WSDLReaderImpl.java:2198)
        at com.ibm.wsdl.xml.WSDLReaderImpl.parseSchema(WSDLReaderImpl.java:830)
        at com.ibm.wsdl.xml.WSDLReaderImpl.parseSchema(WSDLReaderImpl.java:654)
        at com.ibm.wsdl.xml.WSDLReaderImpl.parseTypes(WSDLReaderImpl.java:610)
        at com.ibm.wsdl.xml.WSDLReaderImpl.parseDefinitions(WSDLReaderImpl.java:320)
        at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(WSDLReaderImpl.java:2352)
        at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(WSDLReaderImpl.java:2338)
        at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:255)
        at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:165)
        at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:85)
        ... 8 more
    Caused by: org.xml.sax.SAXParseExceptionpublicId: file:/; systemId: file:/; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
        at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:257)
        at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)
        at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(WSDLReaderImpl.java:2188)
        ... 17 more
    

    编辑:额外的东西尝试

      • 服务启动的很好。
      • “Host2一定闹鬼了”
    1. 删去
      • 服务以完全相同的方式失败。
      • 被诅咒的

    同样,这是第三个集群。所有这些都在运行约30个其他微服务,没有问题。所有集群通过Ansible和RKE提供,所有服务通过Jenkins和Helm部署。

    0 回复  |  直到 4 年前