• 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

Naming.Lookup problem

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On the client-side I issue the following call to get a reference for the RemoteConnectionFactory which returns instances of DataInterface.
This is the line that generates the exception.
RemoteConnectionFactory rcf = (RemoteConnectionFactory)Naming.lookup("rmi://localhost:1099/ConnectionFactory");

Has anyone else encountered this before?

Exception in thread "main" java.lang.ClassCastException: suncertify.server.RemoteConnectionFact
ory_Stub
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I did. Because you really want to cast it to the interface, not the actual class. Because you are getting stub from the registry, and therefore it implements the interface, but it is not of the class type that you are casting it too.
Does this make sense?
Hope it helps
Mark
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic