IllegalAnnotationsException:javax.xml.bind.JAXBElement没有无参数的默认构造函数

时间:2019-05-27 18:55:41

标签: java soap jaxb

在构建SOAP服务客户端时,我的soap服务创建会引发以下异常:

Caused by: org.apache.cxf.service.factory.ServiceConstructionException
    at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:329)
    at org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86)
    at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:426)
    at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:528)
    at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:263)
    at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:199)
    at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:103)
    at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:91)
    at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:159)
    at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:142)
    at org.apache.cxf.jaxws.ServiceImpl.createPort(ServiceImpl.java:493)
    at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:359)
    ... 64 more
Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
javax.xml.bind.JAXBElement does not have a no-arg default constructor.
    this problem is related to the following location:
        at javax.xml.bind.JAXBElement
        at com.example.abc.runtime.data.exampleservice.generated.Node$NodeTypeString

它抱怨的NodeTypeString类已经有一个no-arg构造函数,如下所示:

public class Node 
{
   public static class NodeTypeString
        extends JAXBElement<String>
    {
        protected final static QName NAME = new QName("http://schemas.datacontract.org/2004/07/Example.Web.ServiceModels", "Type");

        public NodeTypeString(String value) {
            super(NAME, ((Class) String.class), Node.class, value);
        }

        public NodeTypeString() {
            super(NAME, ((Class) String.class), Node.class, null);
        }

    }
}

因此,如果不存在无参默认构造函数,则无法理解为什么JAXB抱怨无参默认构造函数。有没有人见过这个?

0 个答案:

没有答案