Hi Sergey,
unfortunately the StringArrayBodyReader is the only one provider I've added
loading the endPoint at client side.
If it can be useful I do a quick recap of the situation.
- Using swagger u.i that expects a json format the response body is:
["°C"]
and no problem occurs
- This is the reponse I see from web browser when I call the REST web method
http://*****/DMConfigRest/getUnitsOfMeasure/0/12/0/10/0:
["°C"]
(there is an unexpected char: Â, but no problem occurs at the invocation)
- Calling from java code the "No message body reader..." exception occurs
client side.
- In all the cases no exception occurs server side.
- The annotations I've used to tag the ws interface are these:
@WebService(targetNamespace = JettyConstants.DMConfigNameSpace)
@Api(value = "/DMConfigRest", description = "Operations about DataModelConfigurator
service, used from all the actors which want to edit the XML configuration file used by
WSNDataModel")
@Produces({"application/json"})
public interface IDataModelConfig extends IPublishable { ...
@GET
@Path("/getUnitsOfMeasure/{appGardenID}/{protType}/{profileID}/{objectIDhigh}/{objectIDlow}")
@ApiOperation(value = "Tells you what are the units of measure for the
object.",
notes = "Returns the unit of measure of the current object.",
response = String.class, produces="application/xml,application/json")
public String[] getUnitsOfMeasure(
@ApiParam(value = "appGardenID", required = true) @WebParam(name =
"appGardenID") @PathParam("appGardenID") @CxfWSAuthGrain(type=authType.appGarden) int
appGardenID,
@ApiParam(value = "protType", required = true) @WebParam(name = "protType")
@PathParam("protType") short protType,
@ApiParam(value = "profileID", required = true) @WebParam(name =
"profileID") @PathParam("profileID") int profileID,
@ApiParam(value = "objectIDhigh", required = true) @WebParam(name =
"objectIDhigh") @PathParam("objectIDhigh") int objectIDhigh,
@ApiParam(value = "objectIDlow", required = true) @WebParam(name =
"objectIDlow") @PathParam("objectIDlow") int objectIDlow) throws InstantiationException;
....
}
- Now I've added the body reader at client side but I'm not able to arrive in
its readFrom method.
Thanks,
Andrea
Date: Thu, 4 Jul 2013 03:23:44 -0700
From: ml-node+s547215n5730288...@n5.nabble.com
To: bisoma...@hotmail.it
Subject: Re: java.lang.ClassCastException: [B cannot be cast to
[Ljava.lang.Object
Hi Andrea,
Re your earlier email: no problems about the questions, please keep them
coming,
Re this issue: do you have other providers registered ? Other than that,
I can't think of why readFrom is not called
Thanks, Sergey
On 04/07/13 11:15, eanbiso wrote:
Hi Sergey,
I've tried this solution: I've add a BodyReader at clientSide to manage the
response from the server.
I've added this provider:
@Provider
public class StringArrayBodyReader implements MessageBodyReader<String[]> {
private static final Plat1Logger log = new
Plat1Logger(StringArrayBodyReader.class);
@Override
public boolean isReadable(Class<?> arg0, Type arg1,
Annotation[] arg2,
MediaType arg3) {
return String[].class.isAssignableFrom(arg0);
}
@Override
public String[] readFrom(Class<String[]> arg0, Type arg1,
Annotation[] arg2, MediaType arg3,
MultivaluedMap<String, String> arg4,
InputStream arg5)
throws IOException, WebApplicationException {
// TODO Auto-generated method stub
return null;
}
}
at the loading of the REST endPoints:
JAXRSClientFactoryBean proxyFactory = new
JAXRSClientFactoryBean();
proxyFactory.setServiceClass(clazz);
proxyFactory.setAddress(address);
proxyFactory.setProvider(new StringArrayBodyReader());
by the client application.
Debugging I've seen that when I call a REST web method from the client I
arrive in the isReadable method of the provider and it returns true only if
the return type is a String[].... but I' m not yet able to arrive in the
readFrom method of the provider (this even if the isReadable has returned a
true value).
Do you know why this happens?
And how can I fix it and force to call the readFrom method when isReadable
returns true?
In this way I hope to solve the problem.
Thanks a lot,
Andrea
--
View this message in context:
http://cxf.547215.n5.nabble.com/java-lang-ClassCastException-B-cannot-be-cast-to-Ljava-lang-Object-tp5730141p5730271.html
Sent from the cxf-user mailing list archive at Nabble.com.