0
votes

Ive got a RPC problem, so it is not possible to seri. Static classes trough RPC

ive got this in my : ...Impl.java

public static class dateils2  {
    private final String be;
    private final String name;

        public dateils2(String name, String be) {
          this.name = name;
          this.be= be;
        }
      }

it throws :

Type 'com.mi.hu.server.TestImpl$dateils2' was not included in the set of types which can be serialized by this SerializationPolicy or its Class object could not be loaded. For security purposes, this type will not be serialized.: instance = com.mi.hu.server.server.TestImpl$dateils2@33cb8da5

I want to give the datas of a Celltable as Return typ.(mi) Here my Whole Code :

@SuppressWarnings("serial")
public class TestIml extends RemoteServiceServlet implements TestService{
 public static class dateils2  {
        private final String bestellung;
       // private final Date datum;
        private final String name;

        public dateils2(String name, String bestellung) {
          this.name = name;
          //this.datum = datum;
          this.bestellung = bestellung;
        }
      }


Connection con=null;
Statement st=null;
ResultSet rs=null;
String query;
public ArrayList<dateils2> mi = new ArrayList<dateils2>();
String url="jdbc:sqlserver://hp-compaq;instanceName=E;databaseName=Ba";




 public void call()
 {
       try
       {
             Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
       }
       catch(ClassNotFoundException e)
       {
             System.out.print(e.getMessage());
       }
       try
       {
             con=DriverManager.getConnection(url, "f", "f");
             st=con.createStatement();
       }
       catch(SQLException e)
       {
             System.out.println(e.getMessage());
       }
 }
 /**
  * Query
  */




@Override
public ArrayList show() {

    call();

        try
          {
          rs = st.executeQuery("SELECT * FROM BES");


            while(rs.next()){
                mi.add( new dateils2(rs.getString("NA"), rs.getString("BS")));
            }


            con.commit();
          }
          catch (Exception e)
          {
            System.err.println("Error: " + e.getMessage());
            e.printStackTrace();
          }
          finally {

              try {
                        con.close();
                  } catch (SQLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                  }
            }






    // TODO Auto-generated method stub
    return mi;
}

}

1

1 Answers

1
votes

dateils2 is not serializable because:

  • it doesn't have a zero-arg constructor (and non-final fields) or a CustomFieldSerializer
  • it doesn't implement Serializable
  • it's in your server package which is likely not visible from client-side code (you'd generally put DTOs within a shared package, or possibly in your client package; assuming you follow the GWT project layout conventions)

See http://www.gwtproject.org/doc/latest/DevGuideServerCommunication.html#DevGuideSerializableTypes