cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Beryozkin <sberyoz...@gmail.com>
Subject Re: java.lang.ClassCastException: [B cannot be cast to [Ljava.lang.Object
Date Tue, 09 Jul 2013 16:05:42 GMT
Hi, FYI, primitive arrays will be supported when capturing URI 
properties too now, thanks for catching that issue. I guess if we have

?id=1&id=2

then having them mapped to "int[]" instead of "Integer[]" or 
"List<Integer>" should also work

I'm not going to worry though about List<byte[]> or List<String[]> :-)

Thanks, Sergey
On 02/07/13 15:07, Sergey Beryozkin wrote:
> Hi
> On 02/07/13 12:01, eanbiso wrote:
>> Hi Sergey,
>> I'm testing also other endPoints after their RESTization and I've found
>> another problem connected to particular input parameters...
>> I've this ws method:
>>
>>     @GET
>>     @Path("/parseGenCommandArgs")
>>     @ApiOperation(value = "Parses the given set of arguments according
>> to the
>> data model of the given command in order to prepare the XML to be sent to
>> Dory for the realization of the given generic command.",
>>                     notes = "Returns a String representing the XML to
>> be sent to Dory.",
>>                     response = String.class, produces
>> ="application/xml,application/json")
>>     public String parseGenCommandArgs(
>>             @ApiParam(value = "appGardenID", required = true)
>> @WebParam(name =
>> "appGardenID") @QueryParam("appGardenID")
>> @CxfWSAuthGrain(type=authType.appGarden) int appGardenID,
>>             @ApiParam(value = "protType", required = true)
>> @WebParam(name =
>> "protType") @QueryParam("protType")  short protType,
>>             @ApiParam(value = "profileID", required = true)
>> @WebParam(name =
>> "profileID") @QueryParam("profileID") int profileID,
>>             @ApiParam(value = "objectIDhigh", required = true)
>> @WebParam(name =
>> "objectIDhigh") @QueryParam("objectIDhigh") int objectIDhigh,
>>             @ApiParam(value = "objectIDlow", required = true)
>> @WebParam(name =
>> "objectIDlow") @QueryParam("objectIDlow") int objectIDlow,
>>             @ApiParam(value = "args", required = true) @WebParam(name
>> = "args")
>> @QueryParam("args") List<String[]> args) throws Exception;
>>
>> and when I call the method the exception:
>>
>>      java.lang.ClassCastException:
>> sun.reflect.generics.reflectiveObjects.GenericArrayTypeImpl cannot be
>> cast
>> to java.lang.Class
>>
>> occurs on server side, before arriving in the ws method implementor.
>> It is due to the serialization of the List<String[]> input parameter.
>> I've tried to remove the annotation @QueryParam("args") but in this
>> case it
>> continue to not work and a class cast exception occurs client side.
>> Any idea about this problem?
> First of all, thanks for testing the way the JAX-RS runtime maps the
> request info to various parameters. In this specific case, same as with
> the byte[] case, I'd rather see a different type of exception, as
> opposed to ClassCastException, which is a bug.
>
> On the other hand, I don't think a query parameter can be meaningfully
> represented as List<String[]>, I don't know what it means :-). As I said
> the runtime should probably throw a better exception, I need to think
> about it...
>
> IMHO, having SOAP interfaces reused to accept non-SOAP requests works
> reasonably well for simple enough interfaces. When we have complex
> signatures then it'd be better to create a simple RS wrapper which would
> accept the request via some straightforward parameters, then prepare
> parameters in a form expected by a SOAP service implementation, and then
> delegate...
>
> That said, I'll try to get to updating the runtime to behave a bit
> better in cases like this one
>
> Cheers, Sergey
>
>> Thanks,
>>
>> Andrea
>>
>> P.S.
>> For the previous problem it is solved using the Byte[] or removing the
>> @QueryParam annotation.
>>
>>
>>
>> --
>> View this message in context:
>> http://cxf.547215.n5.nabble.com/java-lang-ClassCastException-B-cannot-be-cast-to-Ljava-lang-Object-tp5730141p5730163.html
>>
>> Sent from the cxf-user mailing list archive at Nabble.com.
>>
>
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Mime
View raw message