java rmi passing ImageIcon objects

2019-03-04 08:38发布

I m making an rmi client server based program which is suppose to pass Image object through remote object interfaces. The Client receives an Image from the Server.

Following is my code....

At Client

       public class ImageReceiver
       {
                  public static ImageIcon imageicon;

                  public static void main(String Data[])
                  {

                         imageicon = new ImageIcon(url);
                         imageicon=remoteObject.getImageFromServer();
                  }

        }
        // The Details regarding the binding of remote objects are excluded since they are worling fine...

sendImage is an interfacing method implemented...

        public ImageIcon getImageFromServer() throws RemoteException;

At Server

           public ImageIcon getImageFromServer()
           {
                  ImageIcon ic = new ImageIcon("local url specified");
                  return ic;
           }

         // Much of the Exceptions and other binding details are excluded for simpicity.....

Now the problem is, i m getting an error called

          java.rmi.UnmarshalException: error unmarshalling return
          nested exception is: java.io.EOFException               

Now, Actually i don't have much of any idea how it came... The two major doubts I have is....

Is it possible to send ImageIcon objects through rmi...?? If yes, What could be probably the mistake here. If not, does there exist any simple way to pass Image based objects as parameter through rmi...??

I've also heard somewhere that javax.swing.ImageIcon is serial....but it's not happening in my case

1条回答
走好不送
2楼-- · 2019-03-04 09:13

The same problem occured...when i tried to pass ImageIcon object through RMI....

After a long checking....i found the url i specifed was incorrect.....

it happens...the complier in this often shows Unmarshall exception exactly as you shown.......

try checking your local URL.....

查看更多
登录 后发表回答