RF 'Unfrozen bean with null RequestContext' when using a ValueProxy param with JsonRpc dialect

StackOverflow https://stackoverflow.com/questions/10879512

  •  12-06-2021
  •  | 
  •  

سؤال

When i try to send a request that uses a ValueProxy params i'm getting this 'Unforzen bean' exception. I don't know if this exception is because a bug with RF using JsonDialect or i'm doing something wrong... ¿Some help?

java.lang.AssertionError: Unfrozen bean with null RequestContext
at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.checkStreamsNotCrossed(AbstractRequestContext.java:981)
at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.editProxy(AbstractRequestContext.java:509)
at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.edit(AbstractRequestContext.java:502)
at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.retainArg(AbstractRequestContext.java:1230)
at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.access$2(AbstractRequestContext.java:1223)
at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext$JsonRpcPayloadDialect.addInvocation(AbstractRequestContext.java:202)
at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.addInvocation(AbstractRequestContext.java:661)
at es.xxxx.taller.client.Taller_SomeRequestContextImpl.SomeCall(Taller_SomeRequestContextImpl.java:29)
at es.xxxx.taller.client.Taller.onModuleLoad(Taller.java:417)



public class SomeEntryPoint implements EntryPoint {

@JsonRpcProxy
public interface SomeProxy extends ValueProxy {
    String getSomeProperty();
    void setSomeProperty(String value);
}

@JsonRpcProxy
public interface VoidProxy extends ValueProxy {
}

public interface SomeAutoBeanFactory extends AutoBeanFactory {
    SomeAutoBeanFactory INSTANCE = GWT.create(SomeAutoBeanFactory.class);

    AutoBean<SomeProxy> someProxy();
}

public interface SomeRequestFactory extends RequestFactory {
    SomeRequestFactory INSTANCE = GWT.create(SomeRequestFactory.class);

    SomeRequestContext context();
}

@JsonRpcService
public interface SomeRequestContext extends RequestContext {

    SomeCall SomeCall(SomeProxy proxy);

    @JsonRpcWireName(value = "SomeCall")
    public interface SomeCall extends Request<VoidProxy> {
    }
}

public void onModuleLoad() {

    SomeProxy someProxy = SomeAutoBeanFactory.INSTANCE.someProxy().as();

    someProxy.setSomeProperty("someValue");

    SomeRequestFactory.INSTANCE.context().SomeCall(someProxy).fire();
}
}
هل كانت مفيدة؟

المحلول

Proxies should be created by a RequestContext, not an AutoBeanFactory! Using the JsonRpc dialect doesn't change how you use RequestFactory.

public void onModuleLoad() {
   SomeRequestContext ctx = SomeRequestFactory.INSTANCE.context();
   SomeProxy someProxy = ctx.create(SomeProxy.class);
   someProxy.setSomeProperty("someValue");
   ctx.SomeCall(someProxy).fire();
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top