I see you cross-posted this question on StackOverflow as well, and I responded there.

http://stackoverflow.com/questions/16479366/errai-jaxrs-bad-request/16484008#16484008

-Jonathan

On 2013-05-10, at 5:33 AM, xybrek wrote:

I'm having quite an issue for running Errai-jaxrs with my app I'm getting this error:

org.jboss.errai.enterprise.client.jaxrs.api.ResponseException: Bad Request    
at org.jboss.errai.enterprise.client.jaxrs.AbstractJaxrsProxy$1.onResponseReceived(AbstractJaxrsProxy.java:132)    
at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)    
at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395)    
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)    
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)    
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)    
at java.lang.reflect.Method.invoke(Method.java:474)    
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)    
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)    
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)    
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)    
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)    
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)    
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)    
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)    
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)    
at com.google.gwt.core.client.impl.Impl.apply(Impl.java)    
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)    
at sun.reflect.GeneratedMethodAccessor56.invoke(Unknown Source)    
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)    
at java.lang.reflect.Method.invoke(Method.java:474)    
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)    
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)    
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)    
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)    
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)    
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)    
at java.lang.Thread.run(Thread.java:722)

From the stacktrace it looks like a Bad Request. The backend for this one is RestEasy + Guice which pretty much configured properly, since before I tried using errai-jaxrs I am just using plain GWT RequestBuilder which works fine. I'm not sure where the problem is but here is my code:

CustomerService.java

@Path("/customerservice")
public interface CustomerService {
    @GET
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)     
    public Customer getCustomer(String id);

    @POST
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.TEXT_PLAIN)
    public String createCustomer(Customer Customer);
}


CustomerServiceImpl.java

@Singleton
public class CustomerServiceImpl implements CustomerService {
    @Override
    public Customer getCustomer(String id) {
        return new Customer();
    }

    @Override
    public String createCustomer(Customer Customer) {
        return "1";
    }
}


On the client side:

    @Inject
    private Caller<CustomerService> CustomerService;

    @EventHandler("submit")
    public void createCustomer(ClickEvent event) {   
        event.preventDefault();
        Customer customer = new Customer();
        CustomerService.call(new RemoteCallback<String>() {
            @Override
            public void callback(String response) {
                Window.alert("Customer created: " + response);
            }
        }).createCustomer(customer);
    }


What could be the problem?
_______________________________________________
errai-users mailing list
errai-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/errai-users