ObjectInputStream over sockets Problem
I am trying to call a method on the server from the client. I called a new instance of the class and wrote the new instance as an object to the ObjectOutputStream. I wrote an interface on the client side. Am I able to do this?(or allowed to) Oh yeah the server is on a different machine. The error im getting from the client is:
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: java.lang.Runtime
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1311)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1877)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1801)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1679)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1307)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:357)
at cmd_line.Network.sendFile(Network.java:65)
at cmd_line.EpkgUtil.addEpkg(EpkgUtil.java:201)
at cmd_line.EpkgArchiveClient.go(EpkgArchiveClient.java:198)
at cmd_line.EpkgArchiveClient.main(EpkgArchiveClient.java:214)
Caused by: java.io.NotSerializableException: java.lang.Runtime
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1085)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1423)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1395)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1338)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1083)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:309)
at ServerThreads.run(ServerThreads.java:68)
and from the server im getting:
Exception: java.lang.Runtime
Client code:
oos.writeUTF("file");
oos.writeObject(v);
oos.flush();
EpkgArchiveServerUtil he = (EpkgArchiveServerUtil) objIn.readObject();
he.Test();
objIn.close();
oos.close();
Client interface class:
publicinterface EpkgArchiveServerUtilextends Serializable{
publicvoid Test();
}
Server code:
if(ois.readUTF().equals("file")){
System.out.println("got to the file decider");
Vector v = (Vector) ois.readObject();
EpkgArchiveServerUtil e =new EpkgArchiveServerUtil();
oos.writeObject(e);
oos.flush();
ListIterator iter = v.listIterator();
while(iter.hasNext()){
System.out.println((String)iter.next());
}
ois.close();
oos.close();
oos.close();
}
EpkgArchiveServerUtil class:
publicvoid Test(){
System.out.println("Hell yea it worked");
}

