View Full Version : Problem with GXT 2.0 when nested values are retrieved from ModelData at server side

Rakes H
21 Jul 2009, 1:21 AM
We are using GXT2.0 Final and GWT 1.6.4 for our application.
GWT-RPC is used for server side method invocations and the data for communication is wrapped in ModelData and send across to server.
From the server, the data is retrieved using the get method of ModelData.
This works fine when this retrieval is straight forward. (ie for data.get("name");)
But where ever the Nested Objects are used, (ie data.get("name.FirstName")),
this is giving an exception as below,

2009-07-16 09:18:33.991::WARN: Nested in java.lang.ExceptionInInitializerError:
java.lang.UnsupportedOperationException: ERROR: GWT.create() is only usable in client code! It cannot be called, for example, from server code. If you are
running a unit test, check that your test case extends GWTTestCase and that GWT.create() is not called from within an initializer or constructor.
at com.google.gwt.core.client.GWT.create(GWT.java:85)
at com.extjs.gxt.ui.client.data.BeanModelLookup.<clinit>(BeanModelLookup.java:24)
at com.extjs.gxt.ui.client.data.NestedModelUtil.convertIfNecessary(NestedModelUtil.java:26)
at com.extjs.gxt.ui.client.data.NestedModelUtil.getNestedValue(NestedModelUtil.java:38)
at com.extjs.gxt.ui.client.data.NestedModelUtil.getNestedValue(NestedModelUtil.java:19)
at com.extjs.gxt.ui.client.data.BaseModelData.get(BaseModelData.java:45)
The same code was working fine with GXT 1.2.4 and GWT 1.5 .
Could you please suggest a solution for the same?

Thanks and Regards
Rakes H,

21 Jul 2009, 2:00 AM
I added a check that only converts if not from type ModelData. GWT.create is not avalaible on the server. Will be part of the next release.

Rakes H
28 Jul 2009, 12:26 AM
Hi Sven,
I could see your changes in 2.0.1 release.
But that did not give a complete solution for the issue we face.
In our application, I am trying to get the value for a property id, which is an Integer.
Property 'id' is embedded in ModelData 'ruleGroup', which in turn embedded to the parent ModelData 'input'.
So I am trying to retrieve the value for 'id' as
Integer id = (Integer)(input.get("ruleGroup.id"));
It gives me the same exception as in the previous case.
I debugged this issue further and found that the convertIfNecessary(obj) method of NestedModelUtil processes 'ruleGroup' properly, but when it tries to process 'id',
it bypasses the check in convertIfNecessary method and try to create an instance of BeanModelLookup class. Since this is from server side, it gives an exception as above.
Could you please have a look in to this issue again?

29 Jul 2009, 5:01 AM
Hi Sven,
I am also getting the same problem as Rakes got.

24 Aug 2009, 11:46 AM
I am getting this same issue, but this is a regression for me. I am upgrading from GXT 1.2.4 to GXT 2.0.1 and the code which used to work fine is now broken.
As with Rakas, we are getting an Integer from a nested ModelData.

Here's the stack trace of where the error occurs:
BeanModelLookup.get() line: 33
NestedModelUtil.convertIfNecessary(Object) line: 26
NestedModelUtil.getNestedValue(ModelData, List<String>) line: 34
NestedModelUtil.getNestedValue(ModelData, List<String>) line: 43
NestedModelUtil.getNestedValue(ModelData, String) line: 19
BaseModelData.get(String) line: 45

24 Aug 2009, 11:47 AM
I tried to contact both of the posters ans never got a reply. Can you post a actual testcase? I already did a couple of changes in SVN that could address this.

24 Aug 2009, 11:48 AM
I'm on it!

24 Aug 2009, 12:01 PM
I tried to contact both of the posters ans never got a reply. Can you post a actual testcase? I already did a couple of changes in SVN that could address this.

Attached is a Junit 3 TestCase which fails for me.
Thanks for looking at this.

24 Aug 2009, 12:06 PM
Works fine with my changes. The changes will be part of 2.0.2

24 Aug 2009, 12:13 PM