Dear all: I try to send over a file from the client GUI to the server so it can upload the file from the client GUI to server local disk. However it keep give me this error wt.fc.fcResource/0) wt.util.WTException: The operation: "saveToServer" failed. Nested exception is: wt.util.WTRemoteException: Unable to invoke remote method; nested exception is: java.rmi.MarshalException: error marshalling arguments; nested exception is: java.io.NotSerializableException: java.io.FileInputStream java.io.NotSerializableException: java.io.FileInputStream at java.io.ObjectOutputStream.outputObject(Unknown Source) at java.io.ObjectOutputStream.writeObject(Unknown Source) at wt.method.MethodArgs.writeExternal(MethodArgs.java:173) at java.io.ObjectOutputStream.outputObject(Unknown Source) at java.io.ObjectOutputStream.writeObject(Unknown Source) at sun.rmi.server.UnicastRef.marshalValue(Unknown Source) at sun.rmi.server.UnicastRef.invoke(Unknown Source) at wt.method.MethodServerImpl_Stub.invoke(Unknown Source) at wt.method.RemoteMethodServer.invoke(RemoteMethodServer.java:609) at ext.bose.viewable.VisualUtilServiceFwd.saveToServer(VisualUtilServiceFwd.java:201) at wt.clients.beans.contentholder.ViewablContentHolder.uploadContentItems(ViewablContentHolder.java:2433) at wt.clients.beans.contentholder.ViewablContentHolder.persistContentChanges(ViewablContentHolder.java:1570) at wt.clients.beans.contentholder.ViewablContentHolder.processSaveCommand(ViewablContentHolder.java:1988) at wt.clients.beans.contentholder.ViewablContentHolder.access$700(ViewablContentHolder.java:43) at wt.clients.beans.contentholder.ViewablContentHolder$ActionThread.run(ViewablContentHolder.java:298) Can someone please give me a hand ThaNKS
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 InputStreamis. 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 ?