I am trying to test my JSON based webservice using Junit client. I get a ClientHandlerException for not having no-arg default constructor' on my request object and its super class (AMessageStrategy). When I add theno-arg default constructorto both of them the server throws a exceptionNo suitable constructor found for type [simple type, class javax.xml.bind.JAXBElement]:`. This has put me in a fix.
Ideally I dont want/need to have a no-arg default constructor. The question is, is there a way around it. I just need to serialize a object to json. The object has 2 main fields, a message id and message data. The message data is a pojo.
I have added @XmlRootElement on the request class (no annotations on the fields though).
Please advice, I am kinda stuck. And I am a newbie on Java EE. Let me know if more information is needed on this.
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)
RegistrationRequest is not a POJO. Ideally it should be a POJO for it to work.