Hi Lads,
Since I'm a newbie with Restlet, apologies in advance if this is trivial. I've
been struggling with this since a few days and really can't find the solution
to this problem.
I'm currently simply following the First step tutorial to build a simple
application.
Basically, what I want is to simply send a Contact object from a client running
in GAE to a server running in a Tomcat EE.
I can successfully send Forms using Representations between client and servers
but I would rather use simply Java objects.
The @Get method works fine and a Contact object is returned successfully.
However, if I place a Contact object as a parameter it is always received as
null.
The method causing most problems is the @Put method.
When I call the store method, the client throws the following:
Caused by: Unsupported Media Type (415) - OK
at
org.restlet.resource.ClientResource$1.invoke(ClientResource.java:1648)
at $Proxy32.store(Unknown Source)
while the server side throws:
java.lang.NumberFormatException: Expected type 'int' but received a
non-numerical value:
//OK[0,0,0,0,1,["ie.slicepedia.api.Contact/1106672264"],0,6]
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.getNumberFormatException(ServerSerializationStreamReader.java:825)
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.readInt(ServerSerializationStreamReader.java:491)
Incidently, the server side is also outputting the following warning:
WARNING: The protocol used by this request is not declared in the list of
client connectors. (FILE)
but I don't understand why because I seem to be specifying the protocol in the
CreateInBoundRoot method.
I would really appreciate any help or advice on this topic since this simple
task has been bugging me for a while now.
Thanks very much in advance :-)
My set up is the following. On the server side I'm using a EE server using
Tomcat with the following jars:
EE editions
org.restlet.jar
org.restlet.ext.xml.jar
org.restlet.ext.servlet.jar
org.restlet.ext.net.jar
org.restlet.ext.json.jar
org.restlet.ext.jackson.jar
org.restlet.ext.gwt.jar
org.json.jar
gwt-servlet.jar
My ContactServerResource is similar to the example:
@Get
public Contact retrieve(Contact contact) {
return contact;
}
@Put
public void store(Contact contact) {
ContactServerResource.contact = contact;
}
And CreateInBoundRoot() is
Router router = new Router(getContext());
getConnectorService().getClientProtocols().add(Protocol.FILE);
// Serve the files generated by the GWT compilation step.
File warDir = new File("");
if (!"war".equals(warDir.getName())) {
warDir = new File(warDir, "war/");
}
Directory dir = new Directory(getContext(),
LocalReference.createFileReference(warDir));
router.attachDefault(dir);
router.attach("/slices", ContactServerResource.class);
My Restlet client making calls to this EE server does so within a GAE server.
Client Jars:
GAE editions
org.restlet.jar
org.restlet.ext.servlet.jar
org.restlet.ext.net.jar
org.restlet.ext.json.jar
org.restlet.ext.jackson.jar
org.restlet.ext.gwt.jar
gwt-servlet.jar
ClientResource cr = new ClientResource(
"http://localhost:8080/SlicepediaServer/slices");
ContactResource resource = cr.wrap(ContactResource.class);
// Contact contact = resource.retrieve(new Contact());
resource.store(new Contact());
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2700592