users@jersey.java.net

[Jersey] Re: _at_FormParam exception on GET request

From: Trenton D. Adams <trenton.d.adams_at_gmail.com>
Date: Thu, 14 Apr 2016 00:53:37 -0600

I have the @FormParam on a resource class field. I would have thought that
I could have both @FormParam, and @QueryParam defined in the class, and the
system would simply fill them in when appropriate.

On Thu, Apr 14, 2016 at 12:23 AM, Pavel Bucek <pavel.bucek_at_oracle.com>
wrote:

> Hi Trenton,
>
> Do you have @FormParam used somewhere in your resource?
>
> If so, isn't it on the @GET annotated method? That would be illegal state,
> since GET request cannot have an entity, so the @FromParam parameter cannot
> be used..
>
> Regards,
> Pavel
>
>
> On 14/04/16 08:01, Trenton D. Adams wrote:
>
> I mis-interpreted that text in the spec, but I still see nothing to
> indicate that an exception should be thrown in these circumstances.
>
> On Wed, Apr 13, 2016 at 8:36 PM, Trenton D. Adams <
> <trenton.d.adams_at_gmail.com>trenton.d.adams_at_gmail.com> wrote:
>
>> ​Good day,
>>
>> I'm trying to setup a generic JAX-RS service, with field level variables
>> for the parameters. I'm annotating them with @FormParam, because only
>> the service request that uses post should be setting them. I'm getting an
>> error.
>>
>> Now as far as I can tell, pg. 12 of he JAX-RS spec v2 says that "An
>> implementation SHOULD warn if resource classes with other lifecycles use
>> these annotations on resource class fields or bean properties."
>>
>> I'm taking that to mean that I should NOT be receiving an error here, but
>> some sort of warning.
>>
>> Here's the error...
>>
>> A MultiException has 4 exceptions. They are:
>> 1. java.lang.IllegalStateException: The "@FormParam" is utilized when the
>> request method is GET
>> 2. java.lang.IllegalStateException: The "@FormParam" is utilized when the
>> request method is GET
>> 3. java.lang.IllegalArgumentException: While attempting to resolve the
>> dependencies of com.github.trentonadams.eve.features.ApiKeys errors were
>> found
>> 4. java.lang.IllegalStateException: Unable to perform operation: resolve
>> on com.github.trentonadams.eve.features.ApiKeys​
>>
>> I'm getting the error during a get request to the main service. The only
>> post is this, which is not in use at the time of the call...
>>
>> @POST_at_Path("/post")@Produces(MediaType.TEXT_HTML)@Template(name = MainView.INDEX_JSP)public Response postService() throws URISyntaxException
>> {
>> final URI targetURIForRedirection = new URI(
>> serviceUri.getBaseUri().toString() + "api-keys");
>> return Response.seeOther(targetURIForRedirection).build();
>> }
>>
>>
>> "api-keys" is asctually the main service uri.
>>
>>
>
>