The error is because you are trying to send something over RMI which is not Serializable. This usually ocurrs for one of two reasons: either you have created a new class and forgot to mark it as Serializable, or you are trying to send some sort of system object which it doesn't make sense to send.
In this case. I think the reason is the second one I give. You seem confused about what an InputStream
is. The best way I find to think of an input stream is as a small note of what the software would need to ask the operating system if it wanted to get more data.
Let's imagine that your client is running on a Windows machine and the user wants to send the file "c:\temp\whatever.txt" to the remote system. If the client opens a FileInputStream on the named file, nothing appears to happen immediately. What has happened is that the FileInputStream has asked the operating system where on the disk the file is, and how to read bytes from it. If the client asks to read bytes from the InputStream, each call actually asks the operating system for the next chunk of the file.
Now, if I were to send the InputStream itself to the remote system, all that would arrive is a note of how to ask a Windows to read the next few bytes from a local hard disk. Which would probably be useless even on another Windows machine, and completely pointless on a Unix machine.
If you want to send the content of a file over RMI, you need to load the file into some sort of ovbject (a
String, a byte[], whatever), close the file, and send the loaded data.
Has this helped ?