2011-05-30 78 views
1

我有一個方法返回可序列化對象的列表,我對此方法進行RPC調用,並且一切順利,直到反序列化過程:我收到以下消息:「響應無法反序列化」GWT在RPC調用中反序列化泛型列表

注:這是我的GWT-RPC響應字符串:

// OK [0,2768,3,2,0,2764,3,2,0,2761,3,2,0,2754,3,2,0,2750 , 3,2,0,2610,3,2,0,2606,3,2,0,2603,3,2,0,2600,3,2,9,1 ["java.util.ArrayList/3821976829 "" myPackage.MyEntity/845101117 "," java.lang.Integer/3438268394 "], 0.7] 

DTO

public class MyEntity implements Serializable,IsSerializable 
{ 
    private static final long serialVersionUID = -9032157988566853424L; 

    public MyEntity() 
    { 
     super(); 
    } 

    private Integer _entityId; 


    private String _name; 

    public Integer getEntityId() 
    { 
     return _entityId; 
    } 

    public void setEntityId(Integer entityId) 
    { 
     this._entityId = entityId; 
    } 

    public String getName() 
    { 
     return _name; 
    } 

    public void setName(String _name) 
    { 
     this._name = _name; 
    } 

} 

接口

@RemoteServiceRelativePath("ContributorService.rpc") 
public interface ContributorService extends RemoteService 
{ 
    ArrayList<MyEntity> myMethod(Arg arg); 
} 

public interface ContributorServiceAsync 
    { 

     void myMethod(Arg arg, AsyncCallback<ArrayList<MyEntity>> callback); 

    } 

服務器實施:

@SuppressWarnings("serial") 
public class ContributorServiceImpl extends RemoteServiceServlet implements ContributorService 
{ 

    @Override 
    public ArrayList<MyEntity> myMethod(Arg arg) 
    { 
     ArrayList<MyEntity> myList = new ArrayList<MyEntity>(); 
MyEntity myEntity=new MyEntity(); 
     //code... 
myList .add(myEntity); 
     return myList; 
    } 
} 

感謝您的幫助

+0

我從來沒有見過實現Serializable,IsSerializable類之前,通常只有一個就足夠了。我使用Serializable,並且始終適用於我。 – 2011-05-30 13:49:34

+0

我只使用了序列化,但它沒有工作。 – user405458 2011-05-30 13:52:51

+0

我認爲我的問題是與列表,因爲當我編輯方法返回一個對象而不是列表一切工作正常。 – user405458 2011-05-30 14:01:50

回答

1

謝謝大家的幫助 這是一個愚蠢的錯誤,我仍然無法理解。 我改變了GWT SDK和程序工作,然後我使用舊的SDK,以確保問題從SD發出,但令人驚訝的程序仍然有效':(

我對什麼是過去了解,但更重要我的應用程序:)