chirino/resty-gwt — Issue #76: JSON encoder fails on generics
Author: tmp120210
Created: 2011-11-25 14:36:14+00:00
State: open

Hi!
I'm trying to use resty-gwt for my project, I'm moving from GWT-RPC to JSON to support REST and COMET, so, my DTOs are already written.
I've managed to run resty-gwt samples within my project environment, everything worked great! The very next task is to adopt project real DTOs to the resty-gwt.

If I'll change PizzaOrder from the examples code to this:

public class PizzaOrder implements Serializable {

public F first;
public S second;

public String phone_number;
/***unchanged part of PizzaOrder class***/
}

Then I'll get a Null pointer excpetion when calling
PizzaService service = GWT.create(PizzaService.class);

Here is the stacktrace:
ERROR: Generator 'org.fusesource.restygwt.rebind.RestServiceGenerator' threw an exception while rebinding 'com.firstlinesoftware.ord.shared.PizzaService'. java.lang.NullPointerException: null
at org.fusesource.restygwt.rebind.JsonEncoderDecoderClassCreator.getFields(JsonEncoderDecoderClassCreator.java:670)
at org.fusesource.restygwt.rebind.JsonEncoderDecoderClassCreator.getFields(JsonEncoderDecoderClassCreator.java:680)
at org.fusesource.restygwt.rebind.JsonEncoderDecoderClassCreator.getFields(JsonEncoderDecoderClassCreator.java:666)
at org.fusesource.restygwt.rebind.JsonEncoderDecoderClassCreator.generate(JsonEncoderDecoderClassCreator.java:282)
at org.fusesource.restygwt.rebind.BaseSourceCreator.create(BaseSourceCreator.java:213)
at org.fusesource.restygwt.rebind.JsonEncoderDecoderInstanceLocator.getEncoderDecoder(JsonEncoderDecoderInstanceLocator.java:115)
at org.fusesource.restygwt.rebind.JsonEncoderDecoderInstanceLocator.encodeDecodeExpression(JsonEncoderDecoderInstanceLocator.java:142)
at org.fusesource.restygwt.rebind.JsonEncoderDecoderInstanceLocator.encodeExpression(JsonEncoderDecoderInstanceLocator.java:122)
at org.fusesource.restygwt.rebind.JsonEncoderDecoderClassCreator$1.execute(JsonEncoderDecoderClassCreator.java:313)
at org.fusesource.restygwt.rebind.JsonEncoderDecoderClassCreator$1.execute(JsonEncoderDecoderClassCreator.java:292)
at org.fusesource.restygwt.rebind.BaseSourceCreator.branch(BaseSourceCreator.java:122)
at org.fusesource.restygwt.rebind.BaseSourceCreator.branch(BaseSourceCreator.java:115)
at org.fusesource.restygwt.rebind.JsonEncoderDecoderClassCreator.generate(JsonEncoderDecoderClassCreator.java:292)
at org.fusesource.restygwt.rebind.BaseSourceCreator.create(BaseSourceCreator.java:213)
at org.fusesource.restygwt.rebind.JsonEncoderDecoderInstanceLocator.getEncoderDecoder(JsonEncoderDecoderInstanceLocator.java:115)
at org.fusesource.restygwt.rebind.JsonEncoderDecoderInstanceLocator.encodeDecodeExpression(JsonEncoderDecoderInstanceLocator.java:142)
at org.fusesource.restygwt.rebind.JsonEncoderDecoderInstanceLocator.encodeExpression(JsonEncoderDecoderInstanceLocator.java:122)
at org.fusesource.restygwt.rebind.RestServiceClassCreator.writeMethodImpl(RestServiceClassCreator.java:546)
at org.fusesource.restygwt.rebind.RestServiceClassCreator.generate(RestServiceClassCreator.java:277)
at org.fusesource.restygwt.rebind.BaseSourceCreator.create(BaseSourceCreator.java:213)
at org.fusesource.restygwt.rebind.RestServiceGenerator.generate(RestServiceGenerator.java:39)
at com.google.gwt.core.ext.GeneratorExtWrapper.generate(GeneratorExtWrapper.java:48)
at com.google.gwt.core.ext.GeneratorExtWrapper.generateIncrementally(GeneratorExtWrapper.java:60)
at com.google.gwt.dev.javac.StandardGeneratorContext.runGeneratorIncrementally(StandardGeneratorContext.java:681)
at com.google.gwt.dev.cfg.RuleGenerateWith.realize(RuleGenerateWith.java:41)
at com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.rebind(StandardRebindOracle.java:74)
at com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:285)
at com.google.gwt.dev.shell.ShellModuleSpaceHost.rebind(ShellModuleSpaceHost.java:141)
at com.google.gwt.dev.shell.ModuleSpace.rebind(ModuleSpace.java:585)
at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:455)
at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:49)
at com.google.gwt.core.client.GWT.create(GWT.java:98)
at com.firstlinesoftware.ord.client.proxies.DocumentRouteProxy.(DocumentRouteProxy.java:65)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:465)
at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:49)
at com.google.gwt.core.client.GWT.create(GWT.java:98)

Is there any workaround? I've tried to fix this issue by my own, but failed =)

I'm using restygwt 1.2 from Maven Central.

Thanks a lot for your project!