This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi All, I actually posted this a few days ago in the Sockets forum, but it seems there are not many folks visiting that forum. Hopefully someone here has seen this problem before. Thanks!
I have an interesting problem (at least to me). I am experimenting with ObjectInputStream, ObjectOutputStream and sockets. I have written 2 very simple programs; a server and a client. I am constructing a JFrame on the server and when I hit enter, it will send the JFrame to the client. The Client then creates a new JFrame with the state of the one that was sent. This works great if I am communicating from Windows to Windows, but if I have the server on Unix and the Client on Windows, I get 2 errors. On the Server I get: "java.io.IOException: There is no process to read data written to a pipe. at java.net.SocketOutputStream.socketWrite(Native Method) at java.net.SocketOutputStream.write(SocketOutputStream.java:95) at java.io.ObjectOutputStream.drain(ObjectOutputStream.java:1240) at java.io.ObjectOutputStream.setBlockData(ObjectOutputStream.java:1264) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:385) at ReplicateServer.<init>(ReplicateServer.java:37) at ReplicateServer.main(ReplicateServer.java:50)" On the client I get: "java.io.InvalidClassException: javax.swing.JFrame; Local class not compatible: stream c lassdesc serialVersionUID=-7491023444496277500 local class serialVersionUID=91968438219 42654843 at java.io.ObjectStreamClass.validateLocalClass(ObjectStreamClass.java:523) at java.io.ObjectStreamClass.setClass(ObjectStreamClass.java:567) at java.io.ObjectInputStream.inputClassDescriptor(ObjectInputStream.java:936) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:366) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236) at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1186) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:386) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236) at ReplicateClient.<init>(ReplicateClient.java:20) at ReplicateClient.main(ReplicateClient.java:46)" what's interesting is that on the client, you can see that I am getting the JFrame in the stack trace. So it seems that I am at least getting that information from the stream. Is it possible that some, but not all of the JFrame information is getting sent through the stream? Is this a Java/Unix problem? Any ideas on this are greatly appreciated! Thanks! Barry Here is the client code:
And here is the server code:
One further note: I thought maybe there is a problem because I was not flushing/closing the stream on the server side. I added the new code, but it did not make any difference. [ January 21, 2002: Message edited by: Barry Andrews ]
This may be related to the fact that most unix environments do not have a graphics peer (i.e. not GUI based). Unless you unix environment has access to similar (i.e. XWindows) then you cannot instantiate most peer-based java objects. Sean
Hmmmmm..... The Unix machine is AIX 4.0. It does have GUI. I don't think this would be the problem. Also, I am not trying to show the JFrame on the server side. I am just creating it, sending it over the wire and showing it on the client. Would this make a difference? Other ideas??? Thanks for the input!
Barry [ January 25, 2002: Message edited by: Barry Andrews ]
Joined: Nov 07, 2000
You can't even create them without a graphics peer. This is a big hurdle when you do applications on a unix platform but want to manipulate or render graphics for a web client for instance. Check this out. http://www.jguru.com/faq/view.jsp?EID=121936 Sean