@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

最佳答案

当您同时注释字段和属性时,通常会出现此错误。由于已指定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

09-05 13:24