java - 什么是 java.lang.RuntimeException : org. apache.cxf.service.factory.ServiceConstructionException

标签 java web-services cxf

我是 Web 服务新手。当我尝试创建网络服务时,出现以下错误。

 Error: java.lang.RuntimeException: org.apache.cxf.service.factory.ServiceConstructionException

java.lang.RuntimeException: org.apache.cxf.service.factory.ServiceConstructionException
    at org.apache.cxf.frontend.AbstractServiceFactory.createService(AbstractServiceFactory.java:80)
    at org.apache.cxf.tools.java2wsdl.processor.JavaToWSDLProcessor.process(JavaToWSDLProcessor.java:101)
    at org.apache.cxf.tools.java2ws.JavaToWSContainer.processWSDL(JavaToWSContainer.java:110)
    at org.apache.cxf.tools.java2ws.JavaToWSContainer.execute(JavaToWSContainer.java:75)
    at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:103)
    at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:58)
    at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:40)
    at org.apache.cxf.tools.java2ws.JavaToWS.run(JavaToWS.java:77)
    at org.apache.cxf.tools.java2ws.JavaToWS.main(JavaToWS.java:45)
Caused by: org.apache.cxf.service.factory.ServiceConstructionException
    at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:297)
    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:685)
    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.AbstractServiceFactory.createService(AbstractServiceFactory.java:78)
    ... 8 more
Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 20 counts of IllegalAnnotationExceptions
Class has two properties of the same name "boardingPoint"
    this problem is related to the following location:
        at public java.lang.String com.abhibus.oprs.pojo.booking.PrintTicket.getBoardingPoint()
        at com.abhibus.oprs.pojo.booking.PrintTicket
        at com.abhibus.oprs.pojo.booking.TicketBooking
        at com.abhibus.oprs.pojo.booking.ServicePassengerBookingInfo

这两天我一直在纠结这个问题。 在此场景中,ServicePassengerBookingInfo 扩展了 TicketBooking,而 TicketBooking 扩展了 PrintTicket。我在 Printticket pojo 中定义了一个名为 boardingPoint 的属性。

请告诉我如何解决这个问题

端点来源

public class SaveTicketBookingInfo {

    private Long serviceId;
    private Integer adults;
    private Integer childs;
    private String journeyType;
    private Integer journeyTime;
    private Long startPlaceId;
    private Long endPlaceId;
    private Long loginUserId;
    private String paxSeatDetails[];
    private int totalSeatsBooked = 0;
    private Long categoryCodeId[];
    private Long genderCodeId[];
    private String passengerName[];
    private Double passengerAge[];
    private String seatDetails[];
    private Double fareDetails[];
    private Double forwardAdultFare;
    private Double forwardChildFare;
    private double concPerChildPax = 0;
    private int maxPassengerAllowed;
    private String concApplyToChild;
    private int departureDay[];
    private String srvcPlatformNo[];
    private Double concPriceForward;
    private String bookingTypeForward;
    private Double concPriceReturn;
    private String retConc;    
    private String bookingTypeReturn;
    private Long mealIdReturn[];
    private Long mealIdForward[];
    private Double mPriceReturn[];
    private Double mPriceForward[];
    private Integer mQtyForward[];   
    private Integer mQtyReturn[]; 
    private Long depotIds[];
    private Long srvcStationId[];
    private Long accomodationId[];
    private Double tollsPrice[];
    private String acFlag[];   
    private String ticketType;
    private String cancelTicketType;
    private String stockNumber;
    private String stockKey;
    private String cancelType;   
    private String seatNos;
    private int concNoPassengers;
    private String seatsBooked;
    private Long serviceCategoryId;
    private Long concessionId;
    private Double tollFare;
    private String bookingType;
    private String departureTime;
    private String arrivalTime;
    private Double totalAmount;
    private String cardNumber;
    private Double[] bookingTollFare;   
    private Double returnAdultFare;
    private Double returnChildFare;  
    private int retTotalPax = 0;          
    private Double refundPrice;
    private Double refundSrtPrice;
    private Double refundTollFee;
    private Double refundMealPrice;
    private Double refundAccomPrice;
    private Double refundTotalAmount;
    private Long forwardServiceId;
    private Long returnServiceId;
    private Long stationId[];
    private String searchType;
    private String journeyDate;
    private String returnJourneyDate;
    private String[] platFormNo;
    private boolean agentBooking;
    private boolean eBooking;
    private Auditor auditor; 
}

使用 setter 和 getter 方法

最佳答案

您可以在您发布的堆栈跟踪中看到根本原因:

Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 20 counts of IllegalAnnotationExceptions
Class has two properties of the same name "boardingPoint"
    this problem is related to the following location:
        at public java.lang.String com.abhibus.oprs.pojo.booking.PrintTicket.getBoardingPoint()

这是根本原因 - 隐式或显式地,您正在定义一个具有不明确映射的类,以便两个事物映射到相同的名称。不出所料,这个问题无法解决,因此服务器无法启动。

如果没有 PrintTicket 类的完整源代码,我无法说出导致此问题的原因,但请看看您如何注释其属性。可能是您同时导出字段方法(因此 getter 会与字段发生冲突),或者您有两个匹配的 getter 方法(例如 isBoardingPointgetBoardingPoint)等。

关于java - 什么是 java.lang.RuntimeException : org. apache.cxf.service.factory.ServiceConstructionException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11291408/

相关文章:

java - 如何在Java中创建可插拔组件?

jaxb - [javax.xml.bind.UnmarshalException : unexpected element

java - 仅当目标字段为空时,MapStruct 将字段映射到目标

java - 部署到 WAS Liberty Profile,无需 jax-ws

java - 使用 POST 方法时的 HTTPClient 重定向

java - 在 Apache 服务器上部署 Netbeans REST Web 服务

带 Spring 启动的 CXF

maven - cxf-codegen-plugin 排除 XSD 文件

javascript - 密码保护目录列表器

java - 为面板制作背景图像时遇到问题