Recently I just started to try to integrate GWT 2.2.0 with Restlet JSE 
2.1-SNAPSHOT, but with no success. I always get following exception at the 
client side:

java.io.IOException: Can't parse the enclosed entity
        at Unknown.ZFb(Unknown source:0)
        at Unknown.tic(Unknown source:0)
        at Unknown.G7b(Unknown source:0)
        at Unknown.PD(Unknown source:0)
        at Unknown.AE(Unknown source:0)
        at Unknown.<anonymous>(Unknown source:0)
        at Unknown.Zp(Unknown source:0)

So I wonder to know: Is it possible to use Restlet JSE edition as back end 
service while GWT is used as front end?

Any advice would be appreciated.

The libraries used on my server side are:
gwt-servlet-2.2.0
jackson-core-asl-1.7.4
jackson-mapper-asl-1.7.4
org.osgi.core-4.0.0
org.restlet-2.1-SNAPSHOT (JSE edition)
org.restlet.ext.gwt-2.1-SNAPSHOT (JSE edition)
org.restlet.ext.jackson-2.1-SNPASHOT (JSE edition)

Libraries used on my client side are:
gwt-servlet-2.2.0
gwt-user-2.2.0
org.restlet-2.1-SNAPSHOT (GWT edition)

And here is the source code for my server side:
public class CustomerResource extends ServerResource implements 
ICustomerResource {

    private CustomerService customerService;

    @Put
    public void create(Customer customer) {
        customerService.add(customer);
    }

    @Get
    public List<Customer> fetchAll() {
        return customerService.fetchAll();
    }

    @Put
    public void update(Customer customer) {
        customerService.update(customer);
    }

    @Delete
    public void delete(String customerId) {
        customerService.delete(customerId);
    }

    /**
     * @param args
     * @throws Exception 
     */
    public static void main(String[] args) throws Exception {
        Component component = new Component();
        component.getServers().add(Protocol.HTTP, 8080);
        component.getClients().add(Protocol.JAR);
        
        Directory dir = new 
Directory(component.getContext().createChildContext(),
            LocalReference.createJarReference(
                new Reference("file:///D:/temp/server.war"), ""));
        component.getDefaultHost().attachDefault(dir);
        component.getDefaultHost().attach("/customer", CustomerResource.class);
        component.start();
    }

}

My source code for the gwt client side:
    CustomerResourceProxy customerResource = 
GWT.create(CustomerResourceProxy.class);
    customerResource.getClientResource().setReference("/customer");
    
customerResource.getClientResource().getClientInfo().getAcceptedMediaTypes().add(
        new Preference<MediaType>(MediaType.APPLICATION_JAVA_OBJECT_GWT));
    
    customerResource.fetchAll(new AsyncCallback<List<Customer>>() {
        
        @Override
        public void onSuccess(List<Customer> result) {
            logger.log(Level.INFO, "result size = " + result.size());
            view.setQueryResults(result);
        }
        
        @Override
        public void onFailure(Throwable caught) {
            // TODO Auto-generated method stub
            logger.log(Level.SEVERE, "error here", caught);
        }
    });

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

Reply via email to