Wednesday, March 30, 2016

Getting ClassCastException after GWT upgrade

Below is the sample method i am writing to get selected items and using the values in view calss

public List<TestClass> getSelectedElements(){
       List<TestClass> _items = new ArrayList<TestClass>();
       if(isShowSelectedControl ){
              ListGridRecord[] items = selectedItems.getRecords();
              if(items!= null)
              for (ListGridRecord item : items) {
                     TestClass _item = new TestClass();
       return _items;

while executing " _item.setParents((ArrayList<MyClass>)item.getAttributeAsObject("parent"));"
line its giving a java.lang.ClassCastException:$ cannot be cast to com.proj.shared.MyClass

item.getAttributeAsObject will return a java Object which will have the values of type

is there any way i can get the values as an ArrayList<MyClass> or cast it into ArrayList<MyClass>??

As far as i remember it was working with GWT-2.4.0 & smartgwt-3.0 and it was not giving any casting exception
with upgrade of GWT-2.6.1 and smartgwt-4.1 this problem occurred and its giving casting exception.

Please help

You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment