Problem with persisting embedded fields in GWT DTO?

26 views
Skip to first unread message

Ryan W Sims

unread,
Jan 19, 2011, 10:03:30 PM1/19/11
to objectify...@googlegroups.com
I've got a model class here:
which I'm also using as a GWT DTO. The object gets populated on the client, then sent back to the server to get persisted. I get the following stack trace:
Caused by: java.lang.NullPointerException
at com.google.appengine.api.datastore.DataTypeUtils.checkSupportedSingleValue(DataTypeUtils.java:198)
at com.google.appengine.api.datastore.DataTypeUtils.checkSupportedValue(DataTypeUtils.java:157)
at com.google.appengine.api.datastore.DataTypeUtils.checkSupportedValue(DataTypeUtils.java:123)
at com.google.appengine.api.datastore.Entity.setUnindexedProperty(Entity.java:300)
at com.googlecode.objectify.impl.save.FieldSaver.setEntityProperty(FieldSaver.java:156)
at com.googlecode.objectify.impl.save.LeafFieldSaver.saveValue(LeafFieldSaver.java:92)
at com.googlecode.objectify.impl.save.FieldSaver.save(FieldSaver.java:139)
at com.googlecode.objectify.impl.save.ClassSaver.save(ClassSaver.java:133)
at com.googlecode.objectify.impl.Transmog.save(Transmog.java:342)
at com.googlecode.objectify.impl.EntityMetadata.toEntity(EntityMetadata.java:230)
at com.googlecode.objectify.impl.ObjectifyImpl.put(ObjectifyImpl.java:194)
at com.engayged.dao.impl.VendorDaoImpl.insertVendor(VendorDaoImpl.java:78)
at com.engayged.server.AdminServiceBackend.addVendor(AdminServiceBackend.java:80)
at com.engayged.server.AdminServiceServlet.addVendor(AdminServiceServlet.java:67)
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.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:100)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:562)
... 44 more

which I find pretty incomprehensible. Can some helpful soul glance at my model classes and let me know what I'm doing wrong? I can confirm that the DTO is getting serialized & deserialized correctly, so I'm strongly suspicious that I've just set up my @Embedded fields stupidly, but I'm still a newb as far as Objectify goes.

Any help would be most humbly appreciated.

--
rwsims

Ryan W Sims

unread,
Jan 20, 2011, 9:51:54 AM1/20/11
to objectify...@googlegroups.com
I realized that the link above didn't have some fixes pushed; it should be up to date now.
I do have tests for my dao, they're here
and everything seems to be peachy, it's just when it's called during a GWT session that things fall apart. Very confused.

--
rwsims

Peter Knego

unread,
Jan 20, 2011, 1:22:49 PM1/20/11
to objectify...@googlegroups.com

You could run this under debugger and set a breakpoint on
NullPointerException. Then you could examine the execution stack to
see which field causes it.

Jeff Schnitzer

unread,
Jan 20, 2011, 2:20:34 PM1/20/11
to objectify...@googlegroups.com
I recommend installing JD (or some other decompiler) into Eclipse so
you can look at the GAE SDK source when this sort of thing comes up.
Goog says they're working towards opensourcing the SDK, but until
then...

Here are the relevant lines of DataTypeUtils.java:

/* 197 */ else if (value instanceof Link) {
/* 198 */ int length = ((Link)value).getValue().length();
/* 199 */ if (length > 2038) {
/* 200 */ throw new IllegalArgumentException(prefix + "Link
properties must be " + 2038 + " characters or less. Instead, use " +
Text.class.getName() + ", which can store " + "strings of any
length.");
/* */ }
/* */ }

It looks like your Link object contains a null.

Jeff

Ryan Sims

unread,
Jan 20, 2011, 4:01:10 PM1/20/11
to objectify...@googlegroups.com
On Thu, Jan 20, 2011 at 2:20 PM, Jeff Schnitzer <je...@infohazard.org> wrote:
> I recommend installing JD (or some other decompiler) into Eclipse so
> you can look at the GAE SDK source when this sort of thing comes up.
> Goog says they're working towards opensourcing the SDK, but until
> then...

Very useful it is, thanks! And I found the problem, easy fix. A
million thanks to both of you; I'm the only dev on this project as
yet, and sometimes I miss stupid stuff b/c mine are the only eyes on
the code. Thanks for the responses.

Reply all
Reply to author
Forward
0 new messages