Ah, for some reason I thought that the different parameters would
differentiate the methods to Jersey. We do lots of custom
(de)serialization here and Record gets serialized differently from
Record[ ] (As does Collection<Record>). My brain just didn't flip
back to the inbound thinking.
Thanks,
Gary
On Mon, May 2, 2011 at 12:42 PM, Ryan Stewart <rds6235_at_gmail.com> wrote:
> It doesn't have anything to do with your class or method signatures. It's
> about mapping requests to your methods. You have two methods that both say
> they map to a POST to /{type}/ and consume application/json. How is Jersey
> to know which one of those to map a request to? Something in the request has
> to distinguish between them.
>
> On Mon, May 2, 2011 at 9:34 AM, Gary Moore <gary.moore_at_gmail.com> wrote:
>>
>> Hey guys,
>>
>> I'm trying to allow clients to POST a single object for creation and
>> also POST an array of objects for bulk creation. My method
>> definitions:
>>
>> @Path("")
>> @Consumes({"application/json"})
>> @Produces({"application/json"})
>> public class RecordResource {
>>
>>
>> @POST
>> @Path("{type}/")
>> public Object save(@PathParam("type") String type, Record record)
>> throws Exception { ... }
>>
>>
>> @POST
>> @Path("{type}/")
>> public Object[] save(@PathParam("type") String type, Record[]
>> record) throws Exception {...}
>>
>> }
>>
>> The error when deploying is:
>>
>> SEVERE: Consuming media type conflict. The resource methods public
>> java.lang.Object[] RecordResource.save(java.lang.String,Record[])
>> throws java.lang.Exception and public java.lang.Object
>> RecordResource.save(java.lang.String,Record) throws
>> java.lang.Exception can consume the same media type
>>
>> I poked around and most of what I found on the list had to do with
>> inheritance conflicts. This class isn't extending any other class.
>>
>> I've tried with Arrays and Lists, neither work. I also tried naming
>> the methods with different names.
>>
>> Both methods should consume JSON.
>>
>> Thanks,
>> Gary
>>
>>
>> --
>> Gary Moore
>> http://www.gmoore.net
>
>
--
Gary Moore
http://www.gmoore.net