Serialization Error

23 views
Skip to first unread message

Vincenz Mössenböck

unread,
Apr 13, 2012, 3:08:13 AM4/13/12
to google-we...@googlegroups.com
Hey i got a serialization error in my prject... just don t konw why may be sb can help me. 
Here is my Code where the Error occures with some other things. 

if (listSvc == null) {
    listSvc = GWT.create(ListServices.class);
   }

// Set up the callback object.
   AsyncCallback<BestellungDTO> callback = new AsyncCallback<BestellungDTO>() 
{
 public void onFailure(Throwable caught) {
 caught.printStackTrace();
 Window.alert("A failure occured");
 }

@Override
public void onSuccess(BestellungDTO result) {
Window.alert("Order Okay");
confirmOrder.hide();
}
   };
//Call the data
----->    listSvc.saveOrder( Login.warenkorb.getBest() , lfGesamtpreis, callback);
}
I get my error Where the arrow is
Here you got my Best:
/**
 * 
 */
package project.client.data;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

/**
 * @author Vincenz M�ssenb�ck
 *
 */
public class BestellungDTO implements Serializable{
 
    /**
*/
private static final long serialVersionUID = 1L;

private long ID;

    private Set<BestellpositionDTO> alBestellpositionDTO;

    private KundeDTO oKundeDTO;

    private ZahlungsformDTO oZahlungsformDTO;

    private Date dateBestelldatum;

    private KundenstatistikDTO oKundenstatistikDTO;

    public BestellungDTO() {
    alBestellpositionDTO = new HashSet<BestellpositionDTO>();
        dateBestelldatum = new Date();
    }

    public BestellungDTO(Set<BestellpositionDTO> alBestellpositionDTO, KundeDTO oKundeDTO, ZahlungsformDTO oZahlungsformDTO) {
        this.alBestellpositionDTO = alBestellpositionDTO;
        this.oKundeDTO = oKundeDTO;
        this.oZahlungsformDTO = oZahlungsformDTO;
        dateBestelldatum = new Date();
    }

    public long getID() {
        return ID;
    }

    public void setID(long ID) {
        this.ID = ID;
    }

    public Set<BestellpositionDTO> getalBestellpositionDTO() {
        return alBestellpositionDTO;
    }

    public void setalBestellpositionDTO(Set<BestellpositionDTO> alBestellpositionDTO) {
        this.alBestellpositionDTO = alBestellpositionDTO;
    }

    public Date getDateBestelldatum() {
        return dateBestelldatum;
    }

    public void setDateBestelldatum(Date dateBestelldatum) {
        this.dateBestelldatum = dateBestelldatum;
    }

    public KundeDTO getoKundeDTO() {
        return oKundeDTO;
    }

    public void setoKundeDTO(KundeDTO oKundeDTO) {
        this.oKundeDTO = oKundeDTO;
    }


    /**
* @return the oZahlungsformDTO
*/
public ZahlungsformDTO getoZahlungsformDTO() {
return oZahlungsformDTO;
}

/**
* @param oZahlungsformDTO the oZahlungsformDTO to set
*/
public void setoZahlungsformDTO(ZahlungsformDTO oZahlungsformDTO) {
this.oZahlungsformDTO = oZahlungsformDTO;
}

public KundenstatistikDTO getoKundenstatistikDTO() {
        return oKundenstatistikDTO;
    }

    public void setoKundenstatistikDTO(KundenstatistikDTO oKundenstatistikDTO) {
        this.oKundenstatistikDTO = oKundenstatistikDTO;
    }
}
hope i can get some help from you just don t konw what 2 do anymore nearly same thing works in other part of the code without problems

Philippe Lhoste

unread,
Apr 13, 2012, 11:15:55 AM4/13/12
to Google-We...@googlegroups.com
On 13/04/2012 09:08, Vincenz M�ssenb�ck wrote:
> private Set<BestellpositionDTO> alBestellpositionDTO;

One of the first advices I got for making DTOs is to avoid using interfaces in them.
GWT will try and generate JavaScript for all the interface implementations it can find in
the classpath, which is rather costly, and can fail if it finds a non-serializable
implementation...
In short, use HashSet or similar instead of Set.

--
Philippe Lhoste
-- (near) Paris -- France
-- http://Phi.Lho.free.fr
-- -- -- -- -- -- -- -- -- -- -- -- -- --

l.denardo

unread,
Apr 16, 2012, 3:53:52 AM4/16/12
to Google Web Toolkit
Moreover, Set, just like List, Object etc. is NOT Serializable.
If the interface does not extend Serializable, a serialization error
is thrown. The fact of Set not being serializable is all but obvious,
I think we all forgot this problem with RPC.

Btw, this behavior is documented (in a couple of lines at the bottom
of https://developers.google.com/web-toolkit/doc/latest/DevGuideServerCommunication#DevGuideSerializableTypes)
but interface based RPC worked fine, despite documentation stating the
opposite, until 2.2 i guess, so some of your applications may just
step into this problem when you update your GWT release.

Regards
Lorenzo
Reply all
Reply to author
Forward
0 new messages