java rmi passing ImageIcon objects

一个人想着一个人 提交于 2019-12-02 15:21:32

问题


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:


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.....



来源:https://stackoverflow.com/questions/11117626/java-rmi-passing-imageicon-objects

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!