Hi Alfredo,

If you have the exact same version of your TimelineDataForUpdate class
available of both client and server sides, it should work. Could you send us
a reproducible sample and the stack trace?

BTW, if you can use the Restlet 2.0 in development, you will see
ClientResource and ServerResource classes that can transparently handle
serialization via annotated methods. Internally, it produces something
similar to what you have though.

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com


-----Message d'origine-----
De : AJ [mailto:alfredo.benc...@nasa.gov] 
Envoyé : vendredi 3 juillet 2009 21:39
À : discuss@restlet.tigris.org
Objet : Passing a serialized Java object

Hi,

I trying to pass a java object from client to the serve, as shown below:

##################### CLIENT
public Response setData(String resourceSegment, String queryString,
Serializable object) throws Exception {        
        Reference reference = new Reference(Protocol.HTTP, host, port);
        reference.addSegment(resourceSegment);
        if (queryString != null)
                reference.setQuery(Reference.encode(queryString));
                
        Response response = client.post(reference.toString(), new
ObjectRepresentation<Serializable>(object));
...
..
}
####################

#################### SERVER 
public void handlePost() {
        try {
                if
(MediaType.APPLICATION_JAVA_OBJECT.equals(getRequest().getEntity().getMediaT
ype())) {               
                        ObjectRepresentation<TimelineDataForUpdate> rep =
new ObjectRepresentation<TimelineDataForUpdate>(getRequest().getEntity());
                        TimelineDataForUpdate tml = rep.getObject();
                }
        } catch (IOException ioe) {
                trace.error(ioe);
                getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
        } catch (ClassNotFoundException cnfe) {
                trace.error(cnfe);
                getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
        }
}
###################

Unfortunately, I am getting a ClassNotFoundException at server.  Please let
me know if I am doing something wrong.

Thanks in advance!

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

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

Reply via email to