javagwtjerseyjersey-2.0resty-gwt

RestyGWT + Jersey Error 500 when sending a not null or empty List


Say I have a Jersey Resource somewhat similar to this:

@Path("/test")
public class TestResource{
    @POST
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    public Response test(List<JSONRepresentation> json){
    //some logic that gives different responses, all just Strings
    }
}

And a RestyGWT Service that consumes it like this:

@Path("api/test")
public interface TestService extends RestService{

@POST
public void test(List<JSONRepresentation> json, MethodCallback<String> callback);
}

The thing is that, when I try to access the Resource using the Service, if the List isn't null or empty I get an Internal Server Error that doesn't have anything to do with the server code because I can't even debug the test method logic.

However, when the List is null or empty, the Resource's logic does what it should and I can debug it without any problems.

The contents of the JSONRepresentation don't really seem to matter for this problem.

I have no idea why this is even happening and I couldn't really find any similar questions around, any help would be really appreciated.


Solution

  • Ok, I somehow figured out why the error happened and how to avoid it.

    The thing is, the problem was actually in my json representation, I had defined it with private variables and getters and setters for each one of them (I have some sets and instances of other json representations on it along with other String and primitive variables)

    The thing is that, for some reason I'd really want to know more about of, if a variable with a type of another json representation is set as private, this error happens

    So, I just set that variable as public and everything worked fine, the odd part is that Collections of another json representation classes work fine even as private variables (primitives, String, and Date work fine like that too).