zoukankan      html  css  js  c++  java
  • 使用CXF发布Web Service的错误

    1、
    Exception in thread "main" javax.xml.ws.WebServiceException: Unable to create JAXBContext
     at com.sun.xml.internal.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:153)
     at com.sun.xml.internal.ws.model.AbstractSEIModelImpl.postProcess(AbstractSEIModelImpl.java:83)
     at com.sun.xml.internal.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:244)
     at com.sun.xml.internal.ws.server.EndpointFactory.createSEIModel(EndpointFactory.java:312)
     at com.sun.xml.internal.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:178)
     at com.sun.xml.internal.ws.api.server.WSEndpoint.create(WSEndpoint.java:456)
     at com.sun.xml.internal.ws.api.server.WSEndpoint.create(WSEndpoint.java:475)
     at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.createEndpoint(EndpointImpl.java:213)
     at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.publish(EndpointImpl.java:143)
     at com.sun.xml.internal.ws.spi.ProviderImpl.createAndPublishEndpoint(ProviderImpl.java:102)
     at javax.xml.ws.Endpoint.publish(Endpoint.java:170)
     at com.ws.server.StudentServerTest.main(Unknown Source)
    Caused by: java.security.PrivilegedActionException: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
    java.util.Map is an interface, and JAXB can't handle interfaces.
     this problem is related to the following location:
      at java.util.Map
      at public java.util.Map com.ws.jaxws.GetAllStudentResponse._return
      at com.ws.jaxws.GetAllStudentResponse
    java.util.Map does not have a no-arg default constructor.
     this problem is related to the following location:
      at java.util.Map
      at public java.util.Map com.ws.jaxws.GetAllStudentResponse._return
      at com.ws.jaxws.GetAllStudentResponse

     at java.security.AccessController.doPrivileged(Native Method)
     at com.sun.xml.internal.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:140)
     ... 11 more
    Caused by: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
    java.util.Map is an interface, and JAXB can't handle interfaces.
     this problem is related to the following location:
      at java.util.Map
      at public java.util.Map com.ws.jaxws.GetAllStudentResponse._return
      at com.ws.jaxws.GetAllStudentResponse
    java.util.Map does not have a no-arg default constructor.
     this problem is related to the following location:
      at java.util.Map
      at public java.util.Map com.ws.jaxws.GetAllStudentResponse._return
      at com.ws.jaxws.GetAllStudentResponse

     at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:91)
     at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:436)
     at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:277)
     at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1100)
     at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:143)
     at com.sun.xml.internal.bind.api.JAXBRIContext.newInstance(JAXBRIContext.java:95)
     at com.sun.xml.internal.ws.developer.JAXBContextFactory$1.createJAXBContext(JAXBContextFactory.java:97)
     at com.sun.xml.internal.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:148)
     at com.sun.xml.internal.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:140)
     ... 13 more

    在发布一个webservice的时候出现如上异常,在这里贴一下解决方法:

    原因:在做webServices复杂类型值传递时,返回值的类型不可以用接口类型。例如List应该改为ArrayList,Map改为HashMap等。

    2、发布成功,但是时不时会跳出如下消息

    Caused by: java.lang.IllegalArgumentException: prefix wsdp is not bound to a namespace
    at com.sun.xml.bind.DatatypeConverterImpl._parseQName(DatatypeConverterImpl.java:369)
    at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$23.parse(RuntimeBuiltinLeafInfoImpl.java:817)
    ... 40 more
    DefaultValidationEventHandler: [ERROR]: prefix wsdp is not bound to a namespace 
         Location:  node: [wsd:Types: null]
    DefaultValidationEventHandler: [ERROR]: prefix wsdp is not bound to a namespace 
         Location:  node: [wsd:Types: null]
    javax.xml.bind.UnmarshalException: prefix wsdp is not bound to a namespace
     - with linked exception:

    解决方法:

    删除以下4个jar包

    cxf-services-ws-discovery-api-3.1.4.jar

    cxf-services-ws-discovery-service-3.1.4.jar

    cxf-services-wsn-api-3.1.4.jar

    cxf-services-wsn-core-3.1.4.jar

  • 相关阅读:
    信息安全系统设计基础实验五:通讯协议设计 20135211李行之 20135216刘蔚然
    信息安全系统设计基础实验四:外设驱动程序设计 20135211李行之&20135216刘蔚然
    信息安全系统设计基础第十二周学习总结
    实验三-实时系统的移植 20135211李行之 20135216刘蔚然
    实验二-固件设计 20135211李行之 20135216刘蔚然
    信息安全系统设计基础第十一周学习总结
    信息安全系统设计基础实验一 20135211&20135216
    信息安全设计基础第十周学习总结
    Oracle如何创建表空间、用户及授权
    设置nginx支持虚拟机,支持多域名多网站
  • 原文地址:https://www.cnblogs.com/huadiyatou/p/7729186.html
Copyright © 2011-2022 走看看