Tuesday, November 12, 2013

REST Services, Jersey Implementation, 404 Not Found Issue

Have been working with Jersey Implementation, jsr311-api-1.1.1.jar.  Had a service defined:

    @GET
    @Produces( { "application/json" })   
    public SomeService getSomethings(
            @Context SecurityContext securityContext
            , @QueryParam. . .  . . .  . . .
            , @QueryParam. . .  . . .  . . .
            , @QueryParam("someNumber") Integer someNumber            , @QueryParam. . .  . . .  . . .
            , @QueryParam. . .  . . .  . . .) {

            . . .  . . .  . . .
            . . .  . . .  . . .

    }

For some reason some part of the application was passing the parameter someNumber=true.  This was resulting 404 error code, very generic error code.  After spending a couple of hours trying to troubleshoot the issue, figured out that the parameter someNumber=true was causing the 404 error code.  Then changed the method signature to: 

    @GET
    @Produces( { "application/json" })   
    public SomeService getSomethings(
            @Context SecurityContext securityContext
            , @QueryParam. . .  . . .  . . .
            , @QueryParam. . .  . . .  . . .
            , @QueryParam("sampleSetNumber") String someNumber            , @QueryParam. . .  . . .  . . .
            , @QueryParam. . .  . . .  . . .) {

            . . .  . . .  . . .
            . . .  . . .  . . .


    }
and the error 404 disappeared.  Does this suggest that Jersey Implementation of REST services require request parameters to match the signature?

Any REST validation tools?  or any debugging tools?

No comments:

Post a Comment