Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Naming.Lookup problem

 
Alex Sbityakov
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • 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
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic