I am currently trying to build an application using the 2.0 M6 version of
Restlet.
Ideally, I would like to use the GWT edition to consume resources on a J2EE
edition server. Both are running v2 M6.
The problem I can't seem to solve is that of the remote RPC mechanism, I get a
null pointer exception when trying to call the service using the code attached.
I'm trying to follow the GWT example that was posted on ongwt, but in that
sample the GWT and RPC are in the same servlet context, in the case of my app,
I need the GWT app on one context and the Rest service in a separate context.
Is this possible, is this why it's not working?
Also when I compile the GWT app I get these error messsages, but it still
compiles.
[ERROR] Errors in
'jar:file:/home/kedaly/Libraries/restlet-gwt-2.0snapshot/lib/org.restlet.jar!/org/restlet/client/engine/io/TraceInputStream.java'
[ERROR] Line 42: No source code is available for type
java.io.FilterInputStream; did you forget to inherit a required module?
[ERROR] Line 59: The method write(int) is undefined for the type
PrintStream
[ERROR] Line 71: The method write(byte[], int, int) is undefined for
the type PrintStream
[ERROR] Line 84: The method write(byte[], int, int) is undefined for
the type PrintStream
[ERROR] Errors in
'jar:file:/home/kedaly/Libraries/restlet-gwt-2.0snapshot/lib/org.restlet.jar!/org/restlet/client/engine/io/TraceOutputStream.java'
[ERROR] Line 55: The method flush() of type TraceOutputStream must
override or implement a supertype method
[ERROR] Line 56: The method flush() is undefined for the type
FilterOutputStream
[ERROR] Line 59: The method flush() is undefined for the type
PrintStream
[ERROR] Line 64: The method write(int) of type TraceOutputStream must
override or implement a supertype method
[ERROR] Line 65: The method write(int) is undefined for the type
FilterOutputStream
[ERROR] Line 68: The method write(int) is undefined for the type
PrintStream/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ca.sqm.gwt.client.tabs.websitea;
import ca.sqm.api.data.TestCase;
import ca.sqm.gwt.client.images.ImageResources;
import ca.sqm.gwt.client.tabs.BaseAppTab;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.Label;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.TextBox;
import org.restlet.client.data.MediaType;
import org.restlet.client.data.Preference;
import org.restlet.client.resource.Result;
/**
*
* @author kedaly
*/
public class Websitea extends BaseAppTab {
private final TestProxy testResource = GWT.create(TestProxy.class);
private Label lblServerReply = new Label();
private TextBox txtLastName = new TextBox();
private TextBox txtFirstName = new TextBox();
private TextBox txtAge = new TextBox();
private Button btnGet = new Button(Get From Server);
private Button btnSave = new Button(Save to Server);
public Websitea() {
super(Website Access);
setIcon(ImageResources.INSTANCE.websiteaccess16x16());
add(new Label(Input your text: ));
add(txtFirstName);
add(txtLastName);
add(txtAge);
add(btnGet);
add(btnSave);
add(lblServerReply);
//set up api path
testResource.getClientResource().setReference(/api/testapi);
testResource.getClientResource().getClientInfo().getAcceptedMediaTypes().add(new PreferenceMediaType(MediaType.APPLICATION_JAVA_OBJECT_GWT));
btnGet.addListener(Events.Select,new SelectionListenerButtonEvent() {
@Override
public void componentSelected(ButtonEvent ce) {
testResource.retrieve(new ResultTestCase() {
public void onFailure(Throwable caught) {
Info.display(Error,What we have here is a failure to communicate +caught.getMessage());
StringBuffer buf = new StringBuffer();
for (StackTraceElement ele : caught.getStackTrace()) {
buf.append(ele.toString());
buf.append(br/);
}
lblServerReply.setText(buf.toString());
}
public void onSuccess(TestCase result) {
txtFirstName.setText(result.getFirstName());
txtLastName.setText(result.getLastName());
txtAge.setText(Integer.toString(result.getAge()));
}
});
}