View Full Version : Why ??? serialize NullPointerException - help needed!!!!!

4 Jan 2011, 6:32 PM
Why do I see this NPE which causes my RPC call to fail? :((:((

Caused by: java.lang.NullPointerException
at com.extjs.gxt.ui.client.data.RpcMap.size(RpcMap.java:198)
at com.extjs.gxt.ui.client.data.RpcMap_CustomFieldSerializer.serialize(RpcMap_CustomFieldSerializer.java:30)
... 60 moreWhat makes this inexplicable is that RpcMap initializes the map with:

private transient FastMap<Object> map = new FastMap<Object>();and the so shouldn't it return zero for the size if it's empty?:-/

public int size() {
return map.size(); -->this is where the error is thrown ... RpcMap.size(RpcMap.java:198)
}I have a class that implements Serializable. That class contains a HashMap <Long, BaseModel>
If the Hashmap is the underlying cause as not being serialiazable, shouldn't I be seeing a different message?

GXT 2.2
GWT 2.1.1 or 2.1.0
Running via AppEngine DevMode

Help!!! Shawn

4 Jan 2011, 10:53 PM
Have you tried to reproduce this in a small, standalone testcase that implements EntryPoint?

4 Jan 2011, 11:40 PM
Is it possible, that you serialized the map and try to use it again? In this case, you would loose the data stored in the map, because it's defined transient.

5 Jan 2011, 5:36 PM
Have you tried to reproduce this in a small, standalone testcase that implements EntryPoint?

Tried and failed. The data is complicated so I gave up after finding a work around.

It's weird -- really weird. Here are the types of classes:

ClassOne implements serializable
BaseModel1 extends BaseModel
BaseModel2 extends BaseModel
BaseModel3 extends BaseModelthis failed -- using a setter.

ClassOne c1 = createC1(_baseModel1);
c1.setBM3(_baseModel3);this succeeded -- rewriting to use the constructor

ClassOne c1 = createC1(_baseModel1, _baseModel3);Since the constructor calls this.setBM3(_baseModel3), there is no difference in the data in ClassOne when it (attempts to) return via RPC.

I was able to deploy to appengine without the work-around so this seems a mysterious bug in devmode for app engine. I tried everything before the work around such as rebuilding, recompiling, clearing the browser cache and restarting devmode so am sure it's not a case of it just being an outdated version of one of my classes.

GWT 2.1 or 2.1.1
GXT 2.2.0 or 2.2.1
AE 1.4.0 or 1.3.8

Again, I was not able to reproduce a test case. BaseModel3 contains BaseModel2 which may contain other instances of BaseModel2 and I am not going to try to really replicate my data model to get a replicable test case.