This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Distributed Java and the fly likes pass the File INput Stream to the server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "pass the File INput Stream to the server" Watch "pass the File INput Stream to the server" New topic

pass the File INput Stream to the server


Joined: Jan 07, 2002
Posts: 6
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:
at Source)
at Source)
at wt.method.MethodArgs.writeExternal(
at Source)
at 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(
at ext.bose.viewable.VisualUtilServiceFwd.saveToServer(
at wt.clients.beans.contentholder.ViewablContentHolder.uploadContentItems(
at wt.clients.beans.contentholder.ViewablContentHolder.persistContentChanges(
at wt.clients.beans.contentholder.ViewablContentHolder.processSaveCommand(
at wt.clients.beans.contentholder.ViewablContentHolder.access$700(
at wt.clients.beans.contentholder.ViewablContentHolder$
Can someone please give me a hand
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
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 ?

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Mohammed Yousuff
Ranch Hand

Joined: Oct 17, 2007
Posts: 198
Its really help me .. thanks a lot

My Thoughts :
Try not to become a man of success but rather to become a man of value.
Nitesh Kant

Joined: Feb 25, 2007
Posts: 1638

Hi Mohammed,

Its really not a good idea to WakeTheZombies just to say thanks!

apigee, a better way to API!
subject: pass the File INput Stream to the server
It's not a secret anymore!