lifeline2
lifeline2

Reputation: 69

How to unmarshall json to JAXBElement

I've generated java sources from wadl file through wadl2java maven plugin and wanted to create REST Services through Springboot jersey. It reaches the service but getting below Excetiption :

`Can not construct instance of javax.xml.bind.JAXBElement: no suitable constructor found, can not deserialize from Object value (missing default constructor or creator, or perhaps need to add/enable type information?) at [Source: org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream@198d51da; line: 5, column: 33] 

My Service endpoint is something like this:

@Path("getdetails/")
public class GetdetailsResource {
    
    @POST
    @Consumes({"application/xml", "application/json" })
    @Produces({"application/xml", "application/json" })
    public Response GETDETAILS(InputParameters parameters) {
        '''''
        System.out.println(parameters);
....
        return null;
    }

}

REST calls throws exception while Unmarshalling into creating InputParameters which has JAXBElement jaxbElement;

Somehow the JaxbElement never gets instantiated even with the ObjectMapper as mentioned here

InputParameters class is like below:

XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "carray"
})
@XmlRootElement(name = "InputParameters")
public class InputParameters {
    public InputParameters() {
        // TODO Auto-generated constructor stub
        System.out.println();
    }

    @XmlElementRef(name = "P_CONTRACT_ARRAY", namespace = "http://xmlns.oracle.com/apps/getdetails/", type = JAXBElement.class, required = false)
    protected JAXBElement<APPAXX> carray;


    public JAXBElement<APPAXX> getcarray() {
        return carray;
    }

    public void setcarray(JAXBElement<APPAXX> value) {
        this.carray = value;
    }

}

Upvotes: 0

Views: 95

Answers (0)

Related Questions