users@jersey.java.net

[Jersey] Re: Using MessageBodyReader for multiple parameters

From: Jakub Podlesak <jakub.podlesak_at_oracle.com>
Date: Mon, 13 Jun 2011 09:56:29 +0200

Hello,

i am afraid, the JAX-RS specification does not allow more than
one entity parameter. See 3.3.2.1 of [1]:

--8<--
"Resource methods MUST NOT have more than one parameter that is not
annotated with one of the above-
listed annotations."
-->8--

You can still retain a single business method with two parameters
and introduce a new JAX-RS resource method which would just
do st. like:

@PUT
public String restUpload(final MyCustomerControlEntity entity) {
   return upload(entity.getCustomer(), entity.getControl);
}

HTH,

~Jakub

[1]http://jcp.org/aboutJava/communityprocess/mrel/jsr311/index.html

On 06/11/2011 04:12 PM, Luis Javier de la Garza Trevino wrote:
> The following method does not allow my servlet container to start:
>
> <pre>
> @PUT
> public String upload(final Customer customer, final Control control) {
> // ...
> }
> </pre>
>
> I get, not surprisingly:
>
> <pre>
> SEVERE: Missing dependency for method ... at index 0
> SEVERE: Missing dependency for method ... index 1
> SEVERE: Method, ..., is not recognized as valid resource method.
> </pre>
>
> I have implemented MessageBodyReaders for each type. Removing any of
> the parameters enables the servlet container to start gracefully, so I
> suspect there must be a restriction on the number of parameters that
> will be resolved via Entity-Providers.
>
> The problem is that I<i>NEED</i> these two parameters, since I am
> providing both SOAP and REST support, and of course, I am not in the
> liberty of changing method signatures, and I also do not want to
> create one specific Jersey method and one specific JAX-WS method as
> entry points.
>
> I'm using Jersey 1.7.
>