Hello Raphaele,

As the ObjectRepresentation wraps another Representation to deserialize,
and because the 2 distinct formats are supported, you should help the
objectRepresentation to know which deserializer is going to be used.
If you are using the following constructor, juste set the media type of the
wrapped representation

public ObjectRepresentation(Representation)


best regards,
Thierry Boileau




2014-02-26 18:06 GMT+01:00 Raffaele Gravina <raffaele.grav...@gmail.com>:

> Dear All,
>
> I'm trying to run the very simple Restlet sample app available here
> http://restlet.org/learn/guide/2.2/introduction/first-steps/first-application
>
> I'm trying to run the client on an Android device, but I get the following
> error:
> Unable to convert a [application/json,UTF-8] representation into an object
> of class org.restlet.example.common.Contact
> java.io.IOException: Unable to create the Object representation
>
> org.restlet.engine.converter.DefaultConverter.toObject(DefaultConverter.java:291)
> org.restlet.service.ConverterService.toObject(ConverterService.java:170)
> org.restlet.resource.Resource.toObject(Resource.java:828)
>
> org.restlet.engine.resource.ClientInvocationHandler.invoke(ClientInvocationHandler.java:240)
> $Proxy7.retrieve(Native Method)
>
> org.restlet.example.serialisation.android.activity.ContactActivity$2.run(ContactActivity.java:142)
> java.lang.Thread.run(Thread.java:1096)
> java.lang.IllegalArgumentException: The serialized representation must
> have this media type: application/x-java-serialized-object or this one:
> application/x-java-serialized-object+xml
>
> org.restlet.representation.ObjectRepresentation.<init>(ObjectRepresentation.java:204)
>
> org.restlet.representation.ObjectRepresentation.<init>(ObjectRepresentation.java:133)
>
> org.restlet.representation.ObjectRepresentation.<init>(ObjectRepresentation.java:114)
>
> org.restlet.engine.converter.DefaultConverter.toObject(DefaultConverter.java:288)
>
>
> The only way to make this app working is to use the Restlet 2.1-M4
> version. I tried with 2.2-RC2 and even with the "stable" 2.1.7 Restlet
> release.
>
> I understand the app has been tested with "Restlet Framework 2.1 Milestone
> 4", but it sounds too weird to me that a later stable release such the
> 2.1.7 goes nuts on a trivial example like this one!
>
> The app itself is so simple that I cannot see where the problem might ever
> rely, except for a "bug" of the restlet library itself.
> The only other option I can imagine is that after restlet 2.1-m4, in order
> to have java serialization working fine, there must be some additional
> piece of code to add in the client and/or the server that was not necessary
> with 2.1-m4.
>
>
> Any comments or suggestions will be greatly appreciated.
>
> Best,
>
> Raffaele Gravina
>
> ------------------------------------------------------
>
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3073674
>

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3074729

Reply via email to