gwt-jackson icon indicating copy to clipboard operation
gwt-jackson copied to clipboard

JsonIdentityInfo / Reference - failing to compile GWT NullPointerException

Open kmthinkingrock opened this issue 8 years ago • 0 comments

I am getting a NullPointerException when I try to compile a project that has an ObjectMapper interface defined to support a type that contains a getter annotated with @JsonIdentityReference(alwaysAsId=true). The return of the getter is annotated with:

@JsonIdentityInfo(property = "playerIndex", generator = ObjectIdGenerators.PropertyGenerator.class, resolver = PlayerResolver.class)

It makes sense, I suppose, that "PropertyGenerator" from Jackson is unavailable. I can implement my own to see if it works. In writing this, I am realizing that my resolver is going to extremely tied to Jackson API, including the type of context argument passed to newForDeserialization method of ObjectIdResolver (com.fasterxml.jackson.databind.DeserializationContext).

I added config for a custom deserializer, although for now all it does is return null (The NullObjectReference in question appeared before the empty implementation of a custom deserializer). I can try to not return null, but the deserializer should only be executed at runtime - I was hoping to short circuit the generator if it was having problems).

I am going to keep it, maybe, or just use other classes for the information I am trying to support in the client/server communication. Regardless, here is an excerpt from a GWTTestCase that fails in a related way:

[INFO]       [ERROR] Generator 'com.github.nmorel.gwtjackson.rebind.ObjectMapperGenerator' threw an exception while rebinding 'us.heptet.magewars.webapp.client.GwtTestGameEvent.EventMapper'
[INFO] java.lang.NullPointerException
[INFO]  at com.github.nmorel.gwtjackson.rebind.writer.JTypeName$TypeResolver.typeName(JTypeName.java:91)
[INFO]  at com.github.nmorel.gwtjackson.rebind.writer.JTypeName$TypeResolver.typeName(JTypeName.java:161)
[INFO]  at com.github.nmorel.gwtjackson.rebind.writer.JTypeName$TypeResolver.parameterizedName(JTypeName.java:115)
[INFO]  at com.github.nmorel.gwtjackson.rebind.writer.JTypeName.parameterizedName(JTypeName.java:268)
[INFO]  at com.github.nmorel.gwtjackson.rebind.BeanJsonDeserializerCreator.buildPropertyIdentifierDeserializationInfo(BeanJsonDeserializerCreator.java:806)
[INFO]  at com.github.nmorel.gwtjackson.rebind.BeanJsonDeserializerCreator.buildPropertyDeserializerParameters(BeanJsonDeserializerCreator.java:684)
[INFO]  at com.github.nmorel.gwtjackson.rebind.BeanJsonDeserializerCreator.buildCommonPropertyDeserializerMethods(BeanJsonDeserializerCreator.java:647)
[INFO]  at com.github.nmorel.gwtjackson.rebind.BeanJsonDeserializerCreator.buildDeserializer(BeanJsonDeserializerCreator.java:601)
[INFO]  at com.github.nmorel.gwtjackson.rebind.BeanJsonDeserializerCreator.buildInitDeserializersMethod(BeanJsonDeserializerCreator.java:573)
[INFO]  at com.github.nmorel.gwtjackson.rebind.BeanJsonDeserializerCreator.buildInitPropertiesMethods(BeanJsonDeserializerCreator.java:510)
[INFO]  at com.github.nmorel.gwtjackson.rebind.BeanJsonDeserializerCreator.buildSpecific(BeanJsonDeserializerCreator.java:121)
[INFO]  at com.github.nmorel.gwtjackson.rebind.AbstractBeanJsonCreator.buildClass(AbstractBeanJsonCreator.java:166)
[INFO]  at com.github.nmorel.gwtjackson.rebind.AbstractBeanJsonCreator.create(AbstractBeanJsonCreator.java:107)
[INFO]  at com.github.nmorel.gwtjackson.rebind.AbstractCreator.getJsonDeserializerFromType(AbstractCreator.java:613)
[INFO]  at com.github.nmorel.gwtjackson.rebind.AbstractCreator.getJsonDeserializerFromType(AbstractCreator.java:451)
[INFO]  at com.github.nmorel.gwtjackson.rebind.ObjectMapperCreator.buildNewDeserializerMethod(ObjectMapperCreator.java:222)
[INFO]  at com.github.nmorel.gwtjackson.rebind.ObjectMapperCreator.create(ObjectMapperCreator.java:122)
[INFO]  at com.github.nmorel.gwtjackson.rebind.ObjectMapperGenerator.generate(ObjectMapperGenerator.java:36)
[INFO]  at com.google.gwt.core.ext.IncrementalGenerator.generateNonIncrementally(IncrementalGenerator.java:40)
[INFO]  at com.google.gwt.dev.javac.StandardGeneratorContext.runGeneratorIncrementally(StandardGeneratorContext.java:745)
[INFO]  at com.google.gwt.dev.cfg.RuleGenerateWith.realize(RuleGenerateWith.java:103)
[INFO]  at com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.rebind(StandardRebindOracle.java:78)
[INFO]  at com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:262)
[INFO]  at com.google.gwt.dev.shell.ShellModuleSpaceHost.rebind(ShellModuleSpaceHost.java:144)
[INFO]  at com.google.gwt.dev.shell.ModuleSpace.rebind(ModuleSpace.java:597)
[INFO]  at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:483)
[INFO]  at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:49)

[INFO]  at com.google.gwt.core.shared.GWT.createImpl(GWT.java:83)
[INFO]  at com.google.gwt.core.client.GWT.create(GWT.java:86)
[INFO]  at us.heptet.magewars.webapp.client.GwtTestGameEvent.testSerializeDeserialize(GwtTestGameEvent.java:48)
[INFO]  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[INFO]  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[INFO]  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[INFO]  at java.lang.reflect.Method.invoke(Method.java:498)
[INFO]  at com.google.gwt.junit.client.impl.GWTTestAccessor.invoke(GWTTestAccessor.java:39)
[INFO]  at com.google.gwt.junit.client.impl.GWTRunner.executeTestMethod(GWTRunner.java:226)
[INFO]  at com.google.gwt.junit.client.GWTTestCase.doRunTest(GWTTestCase.java:157)
[INFO]  at junit.framework.TestCase.runTest(TestCase.java:59)
[INFO]  at com.google.gwt.junit.client.GWTTestCase.runBare(GWTTestCase.java:151)
[INFO]  at com.google.gwt.junit.client.GWTTestCase.__doRunTest(GWTTestCase.java:115)
[INFO]  at com.google.gwt.junit.client.impl.GWTRunner.runTest(GWTRunner.java:302)
[INFO]  at com.google.gwt.junit.client.impl.GWTRunner.doRunTest(GWTRunner.java:235)
[INFO]  at com.google.gwt.junit.client.impl.GWTRunner.access$9(GWTRunner.java:229)
[INFO]  at com.google.gwt.junit.client.impl.GWTRunner$TestBlockListener.onSuccess(GWTRunner.java:106)
[INFO]  at com.google.gwt.junit.client.impl.GWTRunner$TestBlockListener.onSuccess(GWTRunner.java:1)
[INFO]  at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:232)
[INFO]  at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:250)
[INFO]  at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:412)
[INFO]  at sun.reflect.GeneratedMethodAccessor47.invoke(Unknown Source)
[INFO]  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[INFO]  at java.lang.reflect.Method.invoke(Method.java:498)
[INFO]  at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
[INFO]  at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:72)
[INFO]  at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
[INFO]  at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:341)
[INFO]  at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:222)
[INFO]  at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:121)
[INFO]  at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:573)
[INFO]  at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:293)
[INFO]  at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
[INFO]  at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
[INFO]  at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:298)
[INFO]  at sun.reflect.GeneratedMethodAccessor46.invoke(Unknown Source)
[INFO]  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[INFO]  at java.lang.reflect.Method.invoke(Method.java:498)
[INFO]  at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
[INFO]  at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:72)
[INFO]  at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
[INFO]  at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:296)
[INFO]  at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:551)
[INFO]  at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:368)
[INFO]  at java.lang.Thread.run(Thread.java:745)
[INFO] [ERROR] Deferred binding failed for 'us.heptet.magewars.webapp.client.GwtTestGameEvent.EventMapper'; expect subsequent failures

kmthinkingrock avatar Sep 26 '16 03:09 kmthinkingrock