Autobean deserialize failing ( Ljava_util_List_2_classLit_0_g$ is not defined )

262 views
Skip to first unread message

Ali Akhtar

unread,
Feb 6, 2015, 6:53:52 AM2/6/15
to google-we...@googlegroups.com
I'm trying out AutoBean for the first time. Serializing a DTO to json on server works great, however when I attempt to deserialize it on the client side, I get this error:

 com.google.gwt.core.client.JavaScriptException: (ReferenceError) : Ljava_util_List_2_classLit_0_g$ is not defined
Console.java:11 Unknown.endVisitType_1_g$(MyModule-0.js@7:63881)
Unknown.traverse_1_g$(MyModule-0.js@18:61742)
Unknown.accept_5_g$(MyModule-0.js@8:61692)
Unknown.maybeCreateCoder_0_g$(MyModule-0.js@12:64206)
Unknown.visitValueProperty_3_g$(MyModule-0.js@8:64221)
Unknown.traverseProperties_0_g$(MyModule-0.js@20:4379)
Unknown.traverse_0_g$(MyModule-0.js@10:4306)
Unknown.accept_4_g$(MyModule-0.js@8:4171)
Unknown.doCoderFor_0_g$(MyModule-0.js@17:63732)
Unknown.getOrReify_0_g$(MyModule-0.js@16:4220)

My code:
final RequestBeanFactory factory = GWT.create(RequestBeanFactory.class);

MyBean result = AutoBeanCodex.decode(factory, MyBean.class, response.getText()).as();

During logging I've verified that response.getText() is returning valid json (its the output of serialization via AutoBean on server)

Any ideas?

Message has been deleted

Ali Akhtar

unread,
Feb 6, 2015, 8:32:19 AM2/6/15
to google-we...@googlegroups.com
Seems like this error only occurs when I try to access a property of the deserialized bean. I changed my code to the following:

Console.debug("Response-- " + response.getText());



AutoBean<MyBean> ab = AutoBeanCodex.decode(factory, MyBean.class, response.getText());
Console.debug("Decode 1");


InitResult result = ab.as();
Console.debug("Decode 2: " + result.toString());


Console.debug("Result: " + result.getValue());




I now get the output:

Response-- {"value":"tesst"}
Decode 1
Decode 2: com.myModule.MyBeanAutoBean$2@1

com.google.gwt.core.client.JavaScriptException: (ReferenceError) : Ljava_util_List_2_classLit_0_g$ is not defined
Unknown.endVisitType_1_g$(MyModule-0.js@7:63876)
Unknown.traverse_1_g$(MyModule-0.js@18:61737)
Unknown.accept_5_g$(MyModule-0.js@8:61687)
Unknown.maybeCreateCoder_0_g$(MyModule-0.js@12:64201)
Unknown.visitValueProperty_3_g$(MyModule-0.js@8:64216)
Unknown.traverseProperties_0_g$(MyModule-0.js@20:4376)
Unknown.traverse_0_g$(MyModule-0.js@10:4303)
Unknown.accept_4_g$(MyModule-0.js@8:4168)
Unknown.doCoderFor_0_g$(MyModule-0.js@17:63727)
Unknown.getOrReify_0_g$(MyModule-0.js@16:4217)




Bean definition:

public interface MyBean extends Serializable
{
   
public String getValue();
   
public void setValue(String value);
}


public interface RequestBeanFactory extends AutoBeanFactory
{
   
public AutoBean<MyBean> myBean();
}



Any ideas?

Jens

unread,
Feb 6, 2015, 8:48:05 AM2/6/15
to google-we...@googlegroups.com
AutoBean<MyBean> ab = AutoBeanCodex.decode(factory, MyBean.class, response.getText());
InitResult result = ab.as();


ab.as() returns MyBean and not InitResult.


-- J.

Alberto Mancini

unread,
Feb 6, 2015, 8:48:24 AM2/6/15
to google-we...@googlegroups.com
Hi,
just tested your code and actually seems to work using gwt/trunk so maybe it has something to do with the version you are using or the 'response' text.


My EntryPoint:
---

RequestBeanFactory factory = GWT.create(RequestBeanFactory.class);

AutoBean<MyBean> ab = AutoBeanCodex.decode(factory, MyBean.class, "{\"value\":\"ciao\"}");

GWT.log("Decode 1");

MyBean result = ab.as();

GWT.log("Decode 2: " + result.toString());

GWT.log("Result: " + result.getValue());

---


Browser console:
 Decode 1
SuperDevModeLogger.java:71 Decode 2: com..._MyBeanAutoBean$2@1
SuperDevModeLogger.java:71 Result: ciao

-----


Cheers,
   A. 

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.
To post to this group, send email to google-we...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Ali Akhtar

unread,
Feb 6, 2015, 8:51:35 AM2/6/15
to google-we...@googlegroups.com
Jens, that was just a typo I made in pasting the code. The actual code has the right class name.

Alberto, I'm on gwt 2.7.0 . Does it work with that? The json string is: {"value":"tesst"}

--
You received this message because you are subscribed to a topic in the Google Groups "Google Web Toolkit" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-web-toolkit/RzsjqX2gGd4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-web-tool...@googlegroups.com.

Ali Akhtar

unread,
Feb 6, 2015, 9:16:45 AM2/6/15
to google-we...@googlegroups.com
When I downgrade to gwt 2.6.0 , the code above works without any modification. It seems that this is a bug within 2.7.0 which appears to be fixed in trunk.

Is there a way to upgrade to the trunk version via maven?

Jens

unread,
Feb 6, 2015, 9:26:18 AM2/6/15
to google-we...@googlegroups.com

Is there a way to upgrade to the trunk version via maven?

SNAPSHOT builds are currently disabled. However you can use https://github.com/manolo/gwt-snapshot/raw/master/ as a temporary maven repo.

-- J.
 

Alberto Mancini

unread,
Feb 6, 2015, 10:49:58 AM2/6/15
to google-we...@googlegroups.com
Hi,
the sample code i sent you actually works even if i switch to gwt 2.7.
(superdevmode).

In my sample i specify the json string inline; i'd try to do the same to investigate further. 

good luck,
   Alberto.

Ali Akhtar

unread,
Feb 8, 2015, 12:39:05 PM2/8/15
to google-we...@googlegroups.com
Hi Alberto,

Were you running this in SDM mode?

I've found that the bug I encounter is in SDM, but in regular / production, it runs without issue.

Ali Akhtar

unread,
Feb 8, 2015, 3:30:15 PM2/8/15
to google-we...@googlegroups.com
This issue was fixed when i switched from 2.7.0 to 2.8.0-Snapshot . However, in the snapshot, beans which have only primitives and Strings work. But, beans that have any collections ( lists / maps) don't work, giving a similar error as this.

I've posted a stacktrace and made a test project to be cloned to reproduce it, here: https://groups.google.com/forum/#!topic/google-web-toolkit/Uf3IUgeUdP8

Jens

unread,
Feb 8, 2015, 5:42:10 PM2/8/15
to google-we...@googlegroups.com
This issue was fixed when i switched from 2.7.0 to 2.8.0-Snapshot . However, in the snapshot, beans which have only primitives and Strings work. But, beans that have any collections ( lists / maps) don't work, giving a similar error as this.

At work we use SDM with incremental compile, GWT 2.8.0-SNAPSHOT and an AutoBean that contains primitives (boolean, String), a Set as well as a Map<String, Set<String>>.

We are decoding the JSON on client side without any problems (encoding happens on server).

-- J.
 

Ali Akhtar

unread,
Feb 8, 2015, 8:05:00 PM2/8/15
to google-we...@googlegroups.com

Any ideas what the issue might be then? Do you use intellij for running SDM? And, can you repro the issue if you clone the repo I linked in the other post?

--

Ali Akhtar

unread,
Feb 8, 2015, 11:06:27 PM2/8/15
to google-we...@googlegroups.com
Thanks for the pointer Jen. When I run SDM directly rather than via intellij (using gwt:run-codeserver goal of the maven plugin), everything works. Whew.

Ali Akhtar

unread,
Feb 10, 2015, 1:25:00 AM2/10/15
to google-we...@googlegroups.com
So AutoBeans seem to be working now, however I'm still getting the 'xxx_classlit_xx not defined' exception when I try to use other gwt classes. For instance the following method:

    public Clerk<D> setEvents(HasValue<?>... fields)
   
{
       
for (HasValue<?> f : fields)
       
{
            f
.addValueChangeHandler( e -> validate() );
       
}
       
return this;
   
}

produces: com.google.gwt.core.client.JavaScriptException: (ReferenceError) : Lcom_google_gwt_user_client_ui_HasValue_2_classLit_0_g$ is not defined

I'm wondering if this is because of my use of lambdas / sourceLevel 1.8 and if I should've stuck to using 1.7.

Jen, in your project, are you using sourceLevel 1.7 or 1.8?
Reply all
Reply to author
Forward
0 new messages