kostas trichas
kostas trichas

Reputation: 3013

GWT JPA - The response could not be deserialized

I use GWT and JPA for persistence. I have created a domain JPA enchanted classes, DAO's and RPC for communication between them. Everything works fine, through RPC the client sends the object to server but could not get response. Server cannot deserialize in a compatible way with the client side. So i cannot use the server callBack back to the client. The exception message is this:

The response could not be deserialized, com.google.gwt.user.client.rpc.SerializationException

Here's a sample code of one of my classes:

@Entity
@Table(name="course")
public class Course implements Serializable {
    private static final long serialVersionUID = 1L;
    private int courseId;
    private String name;
    private List<Group> groups;
    private List<Module> modules;

    public Course() {
    }


    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(unique=true, nullable=false)
    public int getCourseId() {
        return this.courseId;
    }

    public void setCourseId(int courseId) {
        this.courseId = courseId;
    }


    @Column(nullable=false, length=100)
    public String getName() {
        return this.name;
    }

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


    //bi-directional many-to-one association to Group
    @OneToMany(mappedBy="course", fetch=FetchType.LAZY)
    public List<Group> getGroups() {
        return this.groups;
    }

    public void setGroups(List<Group> groups) {
        this.groups = groups;
    }


    //bi-directional many-to-one association to Module
    @OneToMany(mappedBy="course", fetch=FetchType.LAZY)
    public List<Module> getModules() {
        return this.modules;
    }

    public void setModules(List<Module> modules) {
        this.modules = modules;
    }

}

Upvotes: 2

Views: 6982

Answers (5)

MountainRock
MountainRock

Reputation: 594

got it working...after a redeploy of war again...strange..cant point to one specific thing (as i did clear browser cache/eclipse classes output/restart eclipse) Apparently workaround seems to be try redeploying webapp whenever this issue occurs..

Upvotes: 0

kostas trichas
kostas trichas

Reputation: 3013

I used Gilead and it fixed the issue.

Please check the corresponding post: GWT with JPA

Upvotes: 0

kostas trichas
kostas trichas

Reputation: 3013

Well the problem is that my class has @OneToMany association to another class. If i remove the association it work's fine. But it's impossible to that, since I use a normalized relational database

Upvotes: 1

Gursel Koca
Gursel Koca

Reputation: 21300

Once , I have prepared gwt-jpa sample for this question. It is just serialization of JPA entity.. It might give you a clue about what is wrong in your case..

Upvotes: 0

Riley Lark
Riley Lark

Reputation: 20890

If you're using GWT-RPC, make sure that all of the classes you're trying to serialize have a public default (no-argument) constructor and implement Serializable. If you have embedded classes, they must also have a no-arg constructor.

Upvotes: 0

Related Questions