@FormParam exception on GET request

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

@FormParam exception on GET request

Trenton D. Adams
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
@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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: @FormParam exception on GET request

Trenton D. Adams
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 <[hidden email]> 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
@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.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: @FormParam exception on GET request

Pavel Bucek-2
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 <[hidden email]> 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
@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.


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: @FormParam exception on GET request

Trenton D. Adams
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 <[hidden email]> 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 <[hidden email][hidden email]> 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
@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.



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: @FormParam exception on GET request

Pavel Bucek-2
Unfortunately for you, that's not the case.

You can move the declaration of those as respective method parameters and the validation should pass.

Regards,
Pavel

On 14/04/16 08:53, Trenton D. Adams wrote:
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 <[hidden email]> 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 <[hidden email]> 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
@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.




Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: @FormParam exception on GET request

Trenton D. Adams
Yeah, that only complicates my use of JAX-RS/Jersey as an MVC framework.  I'll spend a bit more time to see if creating some sort of abstraction will allow me to do what I normally do in our custom command pattern framework.  I really want the time doing repetitive tasks to be mitigated.

Right now, I'm trying to essentially replicate the setting of parameters as request attributes, by leveraging Jersey's MVC templating, where the JAX-RS service instance itself becomes the model.  Perhaps I just need to have a model class/instance of my own, and set it up within the service method.

I'm also trying to get past the limitation of Jersey, where it's not maintaining state on redirects.  Oh JSR-371, where art thou. :P  But, perhaps I can just use a custom injector or something, to setup the data model on a redirect.  I'll have to see if that's possible in a generic way.

On Thu, Apr 14, 2016 at 1:09 AM, Pavel Bucek <[hidden email]> wrote:
Unfortunately for you, that's not the case.

You can move the declaration of those as respective method parameters and the validation should pass.

Regards,
Pavel


On 14/04/16 08:53, Trenton D. Adams wrote:
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 <[hidden email]> 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 <[hidden email][hidden email]> 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
@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.





Loading...