• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ClassCastException on client.main

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, I am new to RMI can following java.sun.com's tutorial, I develop
the following program , however I keep getting a ClassCastException
when I try to cast the remote ojbect into it's interface . I've been
stuck 2 days and doesn't have a clue yet!
//a remote interface:
public interface MyInterface extends Remote{
...
}
//its implement on server
package server;
public MyImpl extends UnicastRemoteObject implements MyInterface{
...
}
ok , now on the client side,NOTE: different package:
//client code
package client
class Client {
...
String name = "...";
MyInterface remote = (MyInterface)Naming(name); //ClassCastException here
....
}
after all codes are done, I have the rmiregistry started ok,
the server started ok
Now when I try to start running my client, it gave me a ClassCastException on main.
when I try println(Naming(name)), it does return the remote object.
I kind of feel that this problem is somehow related to the path setting . I don't know how and why...
please any help would be greatly appreciated!
Thank you
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic