views:

153

answers:

2

Hi All,

I've created a Java stateless session bean to provide RESTful services to clients, and I get a 404 Not Found erorr when I pass in a parameter with a decimal point (specifically a longitude, e.g. 150.318232). The service works fine if the value passed in is an integer.

Below is a snippet of the code from the relevant method - it was originally generated using the Netbeans wizards.

@GET
    @Produces({"application/json"}) //, "application/xml"

    public MessagesConverter get(@QueryParam("start")
                                 @DefaultValue("0")
                                int start,
                                 ......

                                @QueryParam("longitude")
                                 @DefaultValue("-123456789")
                                long searchPointLongitude,
      ......

I've tried encoding the URL such that the periods / dots are submitted as hex codes, but this still doesn't seem to rectify the problem.

Any help would be appreciated.

Cheers,

Jin

A: 

Unlikely, but make sure your decimal isn't rendering to a string using a locale that the endpoint doesn't like. I've written code in my native locale which rendered decimals using periods (.), only to have that code execute later in locales which render decimals using commas (,), which really upset the endpoint service, even when properly URL-encoded.

lance
A: 

Well in your example your argument is a long - which I assume is what you are trying to use for that query param. But the param you pass in is a double or float, not a long.

Gandalf
Hi Gandalf, I was using the wrong data type for the paramater - changed it to double and it worked fine. Thanks.
Jin Liew