8
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "channelType",
    "channelSubType",
    "suffix",
    "userDetail",
    "cardDetail"
})
@XmlRootElement(name = "CardCreationRequest")
public class CardCreationRequest extends BaseRequest
    implements Serializable
{

    @XmlElement(required = true, type = Integer.class, nillable = true)
    protected Integer channelType;
    @XmlElement(required = true, type = Integer.class, nillable = true)
    protected Integer channelSubType;

    @XmlElement(required = true, nillable = true)
    protected String suffix;

    @XmlElement(name="UserDetail", required = true)
    protected UserDetail userDetail;
    @XmlElement(name="CardDetail",required = true)
    protected CardDetail cardDetail;


}

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "UserDetail", propOrder = {
    "title",
    "lastName",
    "firstName",
    "nickName",
    "dob",
    "addr1",
    "addr2",
    "city",
    "state",
    "county",
    "zip",
    "country",
    "tel",
    "mobtel",
    "telExt",
    "ssn",
    "fein",
    "selfEmployed",
    "middleInitial",
    "mothersmaid",
    "salutation",
    "relation",
    "holderID",
    "others",
    "busNum",
    "busNumExt",
    "faxNum",
    "faxExt",
    "driverlicNum",
    "driverlicState",
    "dependents",
    "fedtaxID",
    "companyName",
    "emerAddr1",
    "emerAddr2",
    "emerCity",
    "emersState",
    "emerZip",
    "emerCounty",
    "emerCountry",
    "emerPhone",
    "emerExt",
    "vip",
    "recipID",
    "pagerNum",
    "maritalStatus",
    "gender",
    "email",
    "language",
    "accessCode",
    "nameOnCard",
    "loginID",
    "itemSrc",
    "birthCity",
    "birthState",
    "hsGradYr",
    "collegeGradYr",
    "maidenName"
    })

public class UserDetail
    implements Serializable
{

    public UserDetail() {
        super();
        // TODO Auto-generated constructor stub
    }

    @XmlElement(required = true, nillable = true)
    protected String title;
    @XmlElement(required = true, nillable = true)
    protected String lastName;
    @XmlElement(required = true, nillable = true)
    protected String firstName;
    @XmlElement(required = true, nillable = true)
    protected String nickName;
    @XmlElement(name = "DOB", required = true, type = String.class, nillable = true)
    @XmlJavaTypeAdapter(Adapter2 .class)
    @XmlSchemaType(name = "date")
    protected Date dob;
    @XmlElement(required = true, nillable = true)
    protected String addr1;
    @XmlElement(required = true, nillable = true)
    protected String addr2;
    @XmlElement(required = true, nillable = true)
    protected String city;
    @XmlElement(required = true, nillable = true)
    protected String state;
    @XmlElement(required = true, nillable = true)
    protected String county;
    @XmlElement(required = true, nillable = true)
    protected String zip;
    @XmlElement(required = true, nillable = true)
    protected String country;
    @XmlElement(required = true, nillable = true)
    protected String tel;
    @XmlElement(required = true, nillable = true)
    protected String mobtel;
    @XmlElement(required = true, nillable = true)
    protected String telExt;
    @XmlElement(name = "SSN", required = true, nillable = true)
    protected String ssn;
    @XmlElement(name = "FEIN", required = true, nillable = true)
    protected String fein;
    @XmlElement(required = true, nillable = true)
    protected String selfEmployed;
    @XmlElement(required = true, nillable = true)
    protected String middleInitial;
    @XmlElement(required = true, nillable = true)
    protected String mothersmaid;
    @XmlElement(required = true, nillable = true)
    protected String salutation;
    @XmlElement(required = true, nillable = true)
    protected String relation;
    @XmlElement(required = true, nillable = true)
    protected String holderID;
    @XmlElement(required = true, nillable = true)
    protected String others;
    @XmlElement(required = true, nillable = true)
    protected String busNum;
    @XmlElement(required = true, nillable = true)
    protected String busNumExt;
    @XmlElement(required = true, nillable = true)
    protected String faxNum;
    @XmlElement(required = true, nillable = true)
    protected String faxExt;
    @XmlElement(required = true, nillable = true)
    protected String driverlicNum;
    @XmlElement(required = true, nillable = true)
    protected String driverlicState;
    @XmlElement(required = true, nillable = true)
    protected String dependents;
    @XmlElement(required = true, nillable = true)
    protected String fedtaxID;
    @XmlElement(required = true, nillable = true)
    protected String companyName;
    @XmlElement(required = true, nillable = true)
    protected String emerAddr1;
    @XmlElement(required = true, nillable = true)
    protected String emerAddr2;
    @XmlElement(required = true, nillable = true)
    protected String emerCity;
    @XmlElement(required = true, nillable = true)
    protected String emersState;
    @XmlElement(required = true, nillable = true)
    protected String emerZip;
    @XmlElement(required = true, nillable = true)
    protected String emerCounty;
    @XmlElement(required = true, nillable = true)
    protected String emerCountry;
    @XmlElement(required = true, nillable = true)
    protected String emerPhone;
    @XmlElement(required = true, nillable = true)
    protected String emerExt;
    @XmlElement(name = "VIP", required = true, nillable = true)
    protected String vip;
    @XmlElement(required = true, nillable = true)
    protected String recipID;
    @XmlElement(required = true, nillable = true)
    protected String pagerNum;
    @XmlElement(required = true, nillable = true)
    protected String maritalStatus;
    @XmlElement(required = true, nillable = true)
    protected String gender;
    @XmlElement(required = true, nillable = true)
    protected String email;
    @XmlElement(required = true, nillable = true)
    protected String language;
    @XmlElement(required = true, nillable = true)
    protected String accessCode;
    @XmlElement(required = true, nillable = true)
    protected String nameOnCard;
    @XmlElement(required = true, nillable = true)
    protected String loginID;
    @XmlElement(required = true, nillable = true)
    protected String itemSrc;
    @XmlElement(required = true, nillable = true)
    protected String birthCity;
    @XmlElement(required = true, nillable = true)
    protected String birthState;
    @XmlElement(name = "HSGradYr", required = true, type = Integer.class, nillable = true)
    protected Integer hsGradYr;
    @XmlElement(name = "CollegeGradYr", required = true, type = Integer.class, nillable = true)
    protected Integer collegeGradYr;
    @XmlElement(required = true, nillable = true)
    protected String maidenName;
    @XmlElement(required = true, nillable = true)




}

SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'CardsWS': Invocation of init method failed; nested exception is javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:962)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1603)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException
    at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:357)
    at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:246)
    at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:525)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1581)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1522)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
    ... 26 more
Caused by: org.apache.cxf.service.factory.ServiceConstructionException
    at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:324)
    at org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86)
    at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:474)
    at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:690)
    at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:536)
    at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:248)
    at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:205)
    at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:101)
    at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:159)
    at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:211)
    at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:442)
    at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:329)
    ... 35 more
Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
There are two properties named "title" 
    this problem is related to the following location:
        at public java.lang.String wavecrest.orchestration.cardmanger.dto.UserDetail.getTitle()
        at wavecrest.orchestration.cardmanger.dto.UserDetail
        at protected wavecrest.orchestration.cardmanger.dto.UserDetail wavecrest.orchestration.cardmanger.dto.CardCreationRequest.userDetail
        at wavecrest.orchestration.cardmanger.dto.CardCreationRequest
        at private wavecrest.orchestration.cardmanger.dto.CardCreationRequest wavecrest.orchestration.endpoint.jaxws_asm.CreateCard.arg0
        at wavecrest.orchestration.endpoint.jaxws_asm.CreateCard
    this problem is related to the following location:
        at protected java.lang.String wavecrest.orchestration.cardmanger.dto.UserDetail.title
        at wavecrest.orchestration.cardmanger.dto.UserDetail
        at protected wavecrest.orchestration.cardmanger.dto.UserDetail wavecrest.orchestration.cardmanger.dto.CardCreationRequest.userDetail
        at wavecrest.orchestration.cardmanger.dto.CardCreationRequest
        at private wavecrest.orchestration.cardmanger.dto.CardCreationRequest wavecrest.orchestration.endpoint.jaxws_asm.CreateCard.arg0
        at wavecrest.orchestration.endpoint.jaxws_asm.CreateCard
Class has two properties of the same name "title"
    this problem is related to the following location:
        at public java.lang.String wavecrest.orchestration.cardmanger.dto.UserDetail.getTitle()
        at wavecrest.orchestration.cardmanger.dto.UserDetail
        at protected wavecrest.orchestration.cardmanger.dto.UserDetail wavecrest.orchestration.cardmanger.dto.CardCreationRequest.userDetail
        at wavecrest.orchestration.cardmanger.dto.CardCreationRequest
        at private wavecrest.orchestration.cardmanger.dto.CardCreationRequest wavecrest.orchestration.endpoint.jaxws_asm.CreateCard.arg0
        at wavecrest.orchestration.endpoint.jaxws_asm.CreateCard
    this problem is related to the following location:
        at protected java.lang.String wavecrest.orchestration.cardmanger.dto.UserDetail.title
        at wavecrest.orchestration.cardmanger.dto.UserDetail
        at protected wavecrest.orchestration.cardmanger.dto.UserDetail wavecrest.orchestration.cardmanger.dto.CardCreationRequest.userDetail
        at wavecrest.orchestration.cardmanger.dto.CardCreationRequest
        at private wavecrest.orchestration.cardmanger.dto.CardCreationRequest wavecrest.orchestration.endpoint.jaxws_asm.CreateCard.arg0
        at wavecrest.orchestration.endpoint.jaxws_asm.CreateCard

    at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:102)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:472)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:302)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1140)
    at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:154)
    at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:121)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:202)
    at javax.xml.bind.ContextFinder.find(ContextFinder.java:363)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
    at org.apache.cxf.common.jaxb.JAXBContextCache$2.run(JAXBContextCache.java:268)
    at org.apache.cxf.common.jaxb.JAXBContextCache$2.run(JAXBContextCache.java:267)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.cxf.common.jaxb.JAXBContextCache.createContext(JAXBContextCache.java:266)
    at org.apache.cxf.common.jaxb.JAXBContextCache.getCachedContextAndSchemas(JAXBContextCache.java:172)
    at org.apache.cxf.jaxb.JAXBDataBinding.createJAXBContextAndSchemas(JAXBDataBinding.java:454)
    at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:322)
    ... 46 more
4

4 回答 4

13

当您同时注释字段和属性时,通常会出现此错误。由于您已指定XmlAccessType.FIELD,您应该只注释字段(实例变量)。

你有

@XmlAccessorType(XmlAccessType.FIELD)
public class UserDetail {

    @XmlElement
    private String title;

    @XmlElement
    public String getTitle() {
        return title;
    }

}

改成:

@XmlAccessorType(XmlAccessType.FIELD)
public class UserDetail {

    @XmlElement
    private String title;

    public String getTitle() {
        return title;
    }

}

这符合异常告诉您的内容。它指向UserDetail.getTitle()UserDetail.title

Class has two properties of the same name "title"
    this problem is related to the following location:
        at public java.lang.String wavecrest.orchestration.cardmanger.dto.UserDetail.getTitle()
        at wavecrest.orchestration.cardmanger.dto.UserDetail
        at protected wavecrest.orchestration.cardmanger.dto.UserDetail wavecrest.orchestration.cardmanger.dto.CardCreationRequest.userDetail
        at wavecrest.orchestration.cardmanger.dto.CardCreationRequest
        at private wavecrest.orchestration.cardmanger.dto.CardCreationRequest wavecrest.orchestration.endpoint.jaxws_asm.CreateCard.arg0
        at wavecrest.orchestration.endpoint.jaxws_asm.CreateCard
    this problem is related to the following location:
        at protected java.lang.String wavecrest.orchestration.cardmanger.dto.UserDetail.title
        at wavecrest.orchestration.cardmanger.dto.UserDetail
        at protected wavecrest.orchestration.cardmanger.dto.UserDetail wavecrest.orchestration.cardmanger.dto.CardCreationRequest.userDetail
        at wavecrest.orchestration.cardmanger.dto.CardCreationRequest
        at private wavecrest.orchestration.cardmanger.dto.CardCreationRequest wavecrest.orchestration.endpoint.jaxws_asm.CreateCard.arg0
        at wavecrest.orchestration.endpoint.jaxws_asm.CreateCard
于 2012-11-30T10:48:58.800 回答
9

通过调试 IllegalAnnotationsException 类的Builder内部类的check() 方法,您可以找到哪些类和哪些方法有问题 - 以及详细的消息。

查看IllegalAnnotationsException列表中的条目。

我正在使用 jaxb-impl-2.2.11

于 2017-06-12T06:04:37.070 回答
0

我遇到的另一个原因是一些被序列化的类没有无参数构造函数。

于 2019-10-30T18:47:48.680 回答
0

只是为这个错误添加另一个可能的原因:

当我将运算符从我们的主代码迁移到其他团队可以使用的独立库时,我遇到了这个问题。我们的设计要求操作员可以从我们自己的项目的任一位置使用,所以我只是将一大堆代码复制/粘贴到另一个项目中并将其打包到一个 lib 中,然后将该 lib 添加到 lib 目录中。但是,当我使用这个配置运行它时,我得到了这个重复的注释错误。为了解决这个问题,我只需要修改@XmlType 名称参数。我所做的只是将“Op”添加到库中的所有注释名称中。无需进行其他更改。

于 2018-06-29T23:01:34.220 回答