lundi 26 juin 2017

Reflections error: java.lang.IllegalArgumentException: wrong number of arguments

I'm developing a RESTfull web application and I keep getting a IllegalArgumentException on this piece of code:

@GET
@Path("/{parent}/subjects/{title}/comments")
@Produces(MediaType.APPLICATION_JSON)
public Collection<Comment> getSubjectComments(@PathParam("parent") String 
  parent, @PathParam("title") String title){

    Subject s = null;
    try {
        s = Database.getSubject(URLDecoder.decode(parent, "UTF-
  8"),URLDecoder.decode(title, "UTF-8"));
    } catch (UnsupportedEncodingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    if(s!=null){
        return s.getComments();
    }

    return null;
}

What I'm trying to do is get all the comments associated with the Subject s (each subjects has its own ArrayList of comments and that is what is the return value of s.getComments() )

I checked, all argument and variable values are in order.

I believe the main problem has something to do with reflection, but I can't really figure it out.

This is the ajax code that calls the method:

var parentContainer;
function renderComments(){

var currForum = getCookie("forum");
var currSubject = getCookie("subject");

if(parentContainer==null){
    $.ajax({
        url: "/WebApp/app/forums/"+encodeURI(currForum)+"/subjects/"+encodeURI(currSubject)+"/comments",
        type: "GET",
        dataType: "json",

        success: function(data){
            //javascript code
        }
    });
}else{
    $.ajax({
        url: "/WebApp/app/forums/"+encodeURI(currForum)+"/subjects/"+encodeURI(currSubject)+"/comments/"+encodeURI(parentContainer.id)+"/comments",
        type: "GET",
        dataType: "json",

        success: function(data){
            //javascript code
        }
    });
}

}

When the $.ajax call is made, it never enters the success function.

I'm developing the app with Jersey, on Tomcat 7 server, Eclipse.

Thanks in advance.





Aucun commentaire:

Enregistrer un commentaire