users@jersey.java.net

Re: [Jersey] is not recognized as valid Java method annotated with _at_HttpMethod.

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Fri, 30 Jul 2010 14:41:57 +0200

Hi Spencer,

The problem is with the default values for the parameters of type int
e.g.:

> @FormParam("s") @DefaultValue("") int iStart


Change it to:

   @FormParam("s") @DefaultValue("0") int iStart

as the default value in this case needs to be a String value that can
be converted to an int.

Did you see anything else in the logs to indicate that? i think we
could improve the error reporting for this aspect.

Paul.

On Jul 19, 2010, at 7:15 PM, Spencer Tickner wrote:

> Hi List,
>
> Thanks in advance for any help. I've been using Jersey for some time
> but after trying to switch a method over from a get to a post I'm
> getting the following error:
>
> is not recognized as valid Java method annotated with @HttpMethod.
>
> The method looks like:
>
> @POST
> @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_XML, "text/
> css"})
> @Path("simplesearch")
> public byte[] doSimpleSearch(
> @FormParam("q") @DefaultValue("") String sQuery,
> @FormParam("f") @DefaultValue("") String sField,
> @FormParam("s") @DefaultValue("") int iStart,
> @FormParam("e") @DefaultValue("") int iEnd,
> @FormParam("nFrag") @DefaultValue("") int nFrag,
> @FormParam("lFrag") @DefaultValue("") int lFrag,
> @FormParam("fs") @DefaultValue("") String sFilterString,
> @FormParam("lfs") @DefaultValue("") String
> sLastFilterString,
> @FormParam("xsl") String xslPath,
> @FormParam("research") @DefaultValue("") String
> sResearch) throws ParseException, IOException,
> TransformerConfigurationException {
>
> Any thoughts would be much appreciated.
>
> Thanks,
>
> Spencer