sosegon12
sosegon12

Reputation: 61

Deserialization of ArrayList GWT

In my application I'm getting some data from a file located in the server. The data is stored in a text file (.obj), so I'm using an rpc to read the file and get the data. The file is read using a third party library http://www.pixelnerve.com/processing/libraries/objimport/ I'm sending the data to the client using ArrayLists, basicly I'm sending this: ArrayList[ArrayList[Vertex3dDTO]] where Vertex3dDTO is an serializable object with contains float parameters. ArrayList[Vertex3dDTO] is contained in another serializable class Face3dDTO, and ArrayList[Face3dDTO] is in the serializable class Group3dDTO.

package com.nyquicksale.tailorapp.shared;

import java.io.Serializable;

public class Vertex3dDTO implements Serializable {

    float x,y,z;

    public Vertex3dDTO(){

    }

    public Vertex3dDTO(float x, float y, float z){
        this.x = x;
        this.y = y;
        this.z = z;
    }
}

public class Face3dDTO implements Serializable {

    ArrayList<Vertex3dDTO> vL = new ArrayList<Vertex3dDTO>();   
    Vertex3dDTO normal = new Vertex3dDTO();
    Vertex3dDTO color = new Vertex3dDTO();      

    public Face3dDTO(){

    }

    public Face3dDTO(ArrayList<Vertex3dDTO> v) {
        for(Vertex3dDTO v3dDTO : v){            
            vL.add(v3dDTO);         
        }
        updateNormal();
    }

public class Group3dDTO implements Serializable {

    ArrayList<Face3dDTO> fL = new ArrayList<Face3dDTO>();   

    String name;


    public Group3dDTO(){

    }   

    public Group3dDTO(ArrayList<Face3dDTO> f) {     
        for(Face3dDTO f3dDTO : f){
            fL.add(f3dDTO);
        }       
    }
}

Now, everything is working well in development mode, but when I tested the application in hosted mode, everything I receive as response is: //OK[0,1, ["java.util.ArrayList/4159755760"],0,7]

So, I've been checked some other questions and seems the problem is about deserialization, but I've not found anything concrete.

The question is what do I have to do to get the app working well in hosted mode?

Upvotes: 0

Views: 927

Answers (3)

pistolPanties
pistolPanties

Reputation: 1890

Have you made sure this is a serialization problem? You can write a simple RPC test method to pass an array list of your DTO's over the wire in hosted mode.

If I were to bet money on a guess, I would say the problem is those array lists are sent empty in hosted mode. The .obj file read could be the problem. Perhaps in hosted mode the path of file doesn't match as in dev mode(different server configurations perhaps?), since file operations are in a try catch block an exception is most likely swallowed.

Long word short, Did you make sure those array lists are not sent empty in hosted mode?

Upvotes: 0

Chris Cashwell
Chris Cashwell

Reputation: 22899

Your object may well be Serializable, but that doesn't equate to something usable by Remote Procedure Calls. You need to implement Serializable, have a default contructor with no arguments (that calls super() if necessary), and a serial version ID, like so:

public class MyObject implements Serializable {

/**
 * 
 */
private static final long serialVersionUID = -1796729355279100558L;

private Float someValue;

public MyObject() {
    super();
}

public MyObject(Float someValue) {
    super();
    this.someValue = someValue;
}

public Float getSomeValue() {
    return someValue;
}

public void setSomeValue(Float someValue) {
    this.someValue = someValue;
}
}

Upvotes: 0

maneesh
maneesh

Reputation: 1701

To successfully use RPC, your object needs to implement Serializable and should also have a default no arg constructor

Upvotes: 1

Related Questions