我正在尝试使用 Junit 客户端测试我的基于 JSON 的 Web 服务。no-arg default constructor' on my request object and its super class (AMessageStrategy). When I add the
由于没有无参数默认构造函数,我得到一个 ClientHandlerException没有to both of them the server throws a exception
为类型 [简单类型,类 javax.xml.bind.JAXBElement] 找到合适的构造函数:`。这让我陷入了困境。
理想情况下,我不想/不需要拥有no-arg default constructor
. 问题是,有没有办法解决它。我只需要将对象序列化为 json。该对象有 2 个主要字段,一个消息 ID 和消息数据。消息数据是一个pojo。
我在请求类上添加了@XmlRootElement(尽管字段上没有注释)。
请指教,我有点卡住了。我是 Java EE 的新手。让我知道是否需要更多信息。
com.sun.jersey.api.client.ClientHandlerException: javax.ws.rs.WebApplicationException: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
com.mcruiseon.common.message.request.RegistrationRequest does not have a no-arg default constructor.
this problem is related to the following location:
at com.mcruiseon.common.message.request.RegistrationRequest
com.mcruiseon.common.message.AMessageStrategy does not have a no-arg default constructor.
this problem is related to the following location:
at com.mcruiseon.common.message.AMessageStrategy
at com.mcruiseon.common.message.request.RegistrationRequest
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:151)
at com.sun.jersey.api.client.Client.handle(Client.java:648)
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:680)
at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)
at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:568)
at test.carpool4all.Registration.testPost(Registration.java:74)