hello,

I have problem with complex object tree being passed from client side
to server side via RequestFactory:

my proxy interfaces for my model:

@ProxyFor(value = ProductMargin.class, locator =
ProductMarginLocator.class)
public interface ProductMarginProxy extends EntityProxy {

    public long getId();

    public void setId(long id);

    ProductProxy getProduct();

    void setProduct(ProductProxy group);
}


@ProxyFor(value = Product.class)
public interface ProductProxy extends ValueProxy {

    String getVendorId();

    void setVendorId(String title);

    GroupProxy getGroup();

    void setGroup(GroupProxy group);
}


@ProxyFor(value = Group.class)
public interface GroupProxy extends ValueProxy {

    public long getId();

    public void setId(long id);

}

the model is as simple as the proxies:

@Entity
public class Group {
     @Id
     private long id;

     //setters and getters ommited
}

@Entity
public class Product {
     @Id
     private String vendorId;

     @NotNull
     @ManyToOne(cascade = CascadeType.ALL)
     private Group group

     //setters and getters ommited
}

@Entity
public class ProductMargin {
    @Id
     private long id;

    @ManyToOne
     private Product product;

     //setters and getters ommited
}

i try to create new margin for product by using code:

        ProductProxy product; //being read much ealier, wipeout to
make code clear. double checked, is not null, has a property group
initalized properly

        ProductMarginRequest request =
requestFactory.productMarginRequest();
        margin = request.create(ProductMarginProxy.class);
        margin.setProxy(product);
        request.persist(margin).with("product").fire(new
Receiver<Void>() {
                   @Override
                   public void onSuccess(Void response) {
                       Window.alert("success!");
                   }
               });

calling this code produces such error:

00:32:58.409 [ERROR] Uncaught exception escaped
java.lang.NullPointerException: null    at
com.google.gwt.requestfactory.shared.impl.AbstractRequestContext
$MyViolation.<init>(AbstractRequestContext.java:87)     at
com.google.gwt.requestfactory.shared.impl.AbstractRequestContext
$4.onTransportSuccess(AbstractRequestContext.java:629)  at
com.google.gwt.requestfactory.client.DefaultRequestTransport
$1.onResponseReceived(DefaultRequestTransport.java:136)         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:
39)     at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)     at java.lang.reflect.Method.invoke(Method.java:597)     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:
157)    at
com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:
326)    at
com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:
207)    at
com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:
129)    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:214)      at
sun.reflect.GeneratedMethodAccessor151.invoke(Unknown Source)   at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)     at java.lang.reflect.Method.invoke(Method.java:597)     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:
157)    at
com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:
281)    at
com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:
531)    at
com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:
352)    at java.lang.Thread.run(Thread.java:662)

but if you investigate a little bit more and put debug breakpoint in
method

 private void doFire(final Receiver<Void> receiver) from class
AbstractContextRequest on line 613 which is

....
608 requestFactory.getRequestTransport().send(payload, new
TransportReceiver() {
609     public void onTransportFailure(ServerFailure failure) {
610       fail(receiver, failure);
611      }

612      public void onTransportSuccess(String payload) {
613        ResponseMessage response = AutoBeanCodex.decode(
            MessageFactoryHolder.FACTORY, ResponseMessage.class,
payload).as();
...

you will see that the payLoad is:

{"X":[{"M":"may not be null","P":"group","C":
2,"R":"1","T":"pl.myapp.shared.proxy.ProductProxy"}]}

while debugging I checked that GroupProxy property what set till
calling makePayload() method by the AbstractContextRequest which I
think causes problem.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to