I am having a problem with Jackson and JAXB under Apache TomEE 1.6.

The Service class implements a JAX-RS resource with path /test.

The following method works as expected:

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public UserBean read() {
        UserBean userBean = new UserBean();
        userBean.setFirstName("first");
        userBean.setLastName("last");
        return userBean;
    }

Producing the following output:

    {"firstName":"first","lastName":"last"}

However, this method never executes:

    @POST
    @Consumes(MediaType.APPLICATION_JSON)
    public String create(UserBean userBean) {
        System.out.println("userBean="+userBean);
        return "success";
    }

The following JS code in createUser.html is used to pass JSON to the Service
class.

    user = {};
    user.firstName = document.getElementById('firstName').value;
    user.lastName = document.getElementById('lastName').value;
            
    // Submit the form in the background
    var oReq = new XMLHttpRequest();
    oReq.onload = reqListener;

    url = "http://localhost:8080/tomee-jackson-test/test";;
    oReq.open("post", url, true);
    oReq.setRequestHeader("Content-type", "application/json");
    oReq.send(JSON.stringify(user));
                
The JS execution completes, but the println in the Service class does not
execute, nor are any exceptions thrown.

I have uploaded my test project here:
https://github.com/fulltruth/tomee-jackson-test

I read this post:
http://openejb.979440.n4.nabble.com/JSON-serialization-td4662163.html, but
that only covers writing JSON, not reading like I am attempting to do here.

Am I doing something wrong, or is this not supported in TomEE?



--
View this message in context: 
http://openejb.979440.n4.nabble.com/Trying-to-read-JSON-using-Jackson-in-TomEE-tp4668215.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Reply via email to