wood burning stoves
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
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:
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
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 frankcarver.me ~ 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 : http://passion4java.blogspot.com
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!
I agree. Here's the link: http://aspose.com/file-tools
subject: pass the File INput Stream to the server
It's not a secret anymore!