JAXB unmarshal类扩展了抽象类

时间:2013-07-11 15:17:44

标签: java xml spring jaxb jersey

我有两个班级:

@XmlSeeAlso({Recharge.class})
public abstract class Base {

private String id;

@XmlElement(name = "system_id", required = true, type = System.class)
private System system;

@XmlElement(name = "oper", required = true, type = Operation.class)
private Operation operation;

@XmlElement(name = "date", required = true, type = DateTime.class)
@XmlJavaTypeAdapter(DateTimeAdapter.class)
private DateTime dateIn;

@XmlElement(name = "idpay", required = true, type = String.class)
private String idOutSystem;

@XmlElement(name = "card", required = true, type = String.class)
private String cardA;
    ....

public abstract System getSystem();
public String getId() {
        return id;
}

public void setId(String id) {
        this.id = id;
}

public DateTime getDateIn() {
        return dateIn;
}

public void setDateIn(DateTime dateIn) {
        this.dateIn = dateIn;
}

}

@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "req")
public class Recharge extends Base {

    @Override
    public System getSystem() {
        return System.SYSTEM_1;
    }

    @Override
    public Terminal getTerminal() {
        return Terminal.DEFAULT;

    }

    @Override
    public String getCardB() {
        return "";
    }

    @Override
    public String getSp() {
        return "";
    }
}

我被告知我的api:

@POST
@Path("/create")
@Loggable
@Produces(MediaType.APPLICATION_XML)
@Consumes(MediaType.APPLICATION_XML)
public Response handler(Recharge recharge) {
    return Response.status(200).entity(recharge).build();
}

我得到例外:

javax.ws.rs.WebApplicationException: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 13 counts of IllegalAnnotationExceptions
Class has two properties of the same name "amount"
    this problem is related to the following location:
        at public java.lang.Double com.tt.core.domain.base.Base.getAmount()
        at com.tt.core.domain.base.Base
    this problem is related to the following location:
        at private java.lang.Double com.tt.core.domain.base.Base.amount
        at com.tt.core.domain.base.Base
Class has two properties of the same name "cardA"
    this problem is related to the following location:
        at public java.lang.String com.tt.core.domain.base.Base.getCardA()
        at com.tt.core.domain.base.Base
    this problem is related to the following location:
        at private java.lang.String com.tt.core.domain.base.Base.cardA
        at com.tt.core.domain.base.Base
Class has two properties of the same name "currency"
    this problem is related to the following location:
        at public com.tt.core.domain.types.Currency com.tt.core.domain.base.Base.getCurrency()
        at com.tt.core.domain.base.Base
    this problem is related to the following location:
        at private com.tt.core.domain.types.Currency com.tt.core.domain.base.Base.currency
        at com.tt.core.domain.base.Base
Class has two properties of the same name "dateIn"
    this problem is related to the following location:
        at public org.joda.time.DateTime com.tt.core.domain.base.Base.getDateIn()
        at com.tt.core.domain.base.Base
    this problem is related to the following location:
        at private org.joda.time.DateTime com.tt.core.domain.base.Base.dateIn
        at com.tt.core.domain.base.Base
Class has two properties of the same name "debit"
    this problem is related to the following location:
        at public com.tt.core.domain.types.Debit com.tt.core.domain.base.Base.getDebit()
        at com.tt.core.domain.base.Base
    this problem is related to the following location:
        at private com.tt.core.domain.types.Debit com.tt.core.domain.base.Base.debit
        at com.tt.core.domain.base.Base
Class has two properties of the same name "idOutSystem"
    this problem is related to the following location:
        at public java.lang.String com.tt.core.domain.base.Base.getIdOutSystem()
        at com.tt.core.domain.base.Base
    this problem is related to the following location:
        at private java.lang.String com.tt.core.domain.base.Base.idOutSystem
        at com.tt.core.domain.base.Base
Class has two properties of the same name "ip"
    this problem is related to the following location:
        at public java.lang.String com.tt.core.domain.base.Base.getIp()
        at com.tt.core.domain.base.Base
    this problem is related to the following location:
        at private java.lang.String com.tt.core.domain.base.Base.ip
        at com.tt.core.domain.base.Base
Class has two properties of the same name "login"
    this problem is related to the following location:
        at public java.lang.String com.tt.core.domain.base.Base.getLogin()
        at com.tt.core.domain.base.Base
    this problem is related to the following location:
        at private java.lang.String com.tt.core.domain.base.Base.login
        at com.tt.core.domain.base.Base
Class has two properties of the same name "operation"
    this problem is related to the following location:
        at public com.tt.core.domain.types.Operation com.tt.core.domain.base.Base.getOperation()
        at com.tt.core.domain.base.Base
    this problem is related to the following location:
        at private com.tt.core.domain.types.Operation com.tt.core.domain.base.Base.operation
        at com.tt.core.domain.base.Base
Class has two properties of the same name "operator"
    this problem is related to the following location:
        at public com.tt.core.domain.types.Operator com.tt.core.domain.base.Base.getOperator()
        at com.tt.core.domain.base.Base
    this problem is related to the following location:
        at private com.tt.core.domain.types.Operator com.tt.core.domain.base.Base.operator
        at com.tt.core.domain.base.Base
Class has two properties of the same name "phone"
    this problem is related to the following location:
        at public java.lang.String com.tt.core.domain.base.Base.getPhone()
        at com.tt.core.domain.base.Base
    this problem is related to the following location:
        at private java.lang.String com.tt.core.domain.base.Base.phone
        at com.tt.core.domain.base.Base
Class has two properties of the same name "terminal"
    this problem is related to the following location:
        at public abstract com.tt.core.domain.types.Terminal com.tt.core.domain.base.Base.getTerminal()
        at com.tt.core.domain.base.Base
    this problem is related to the following location:
        at private com.tt.core.domain.types.Terminal com.tt.core.domain.base.Base.terminal
        at com.tt.core.domain.base.Base
Class has two properties of the same name "userId"
    this problem is related to the following location:
        at public int com.tt.core.domain.base.Base.getUserId()
        at com.tt.core.domain.base.Base
    this problem is related to the following location:
        at private int com.tt.core.domain.base.Base.userId
        at com.tt.core.domain.base.Base

    at com.sun.jersey.core.provider.jaxb.AbstractRootElementProvider.readFrom(AbstractRootElementProvider.java:115)
    at com.sun.jersey.spi.container.ContainerRequest.getEntity(ContainerRequest.java:488)
    at com.sun.jersey.server.impl.model.method.dispatch.EntityParamDispatchProvider$EntityInjectable.getValue(EntityParamDispatchProvider.java:123)
    at com.sun.jersey.server.impl.inject.InjectableValuesProvider.getInjectableValues(InjectableValuesProvider.java:46)
    at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$EntityParamInInvoker.getParams(AbstractResourceMethodDispatchProvider.java:153)
    at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:203)
    at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
    at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
    at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
    at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1511)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1442)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1391)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1381)
    at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:538)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:716)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:681)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:452)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:138)
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:564)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:213)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1083)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:379)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:175)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1017)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:136)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
    at org.eclipse.jetty.server.Server.handle(Server.java:445)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:260)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:225)
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.run(AbstractConnection.java:358)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:596)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:527)
    at java.lang.Thread.run(Thread.java:722)
...

我如何制作映射,没有这样的错误?在我的非抽象类中只有getter。 补充了课程。在例外情况下,枚举所有字段(及其40多个字段)。

0 个答案:

没有答案
相关问题