• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using Connection Factory,I got java.lang.ClassCastException

 
Jack Yang
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use Factory mode,create a factory server and interface,just on method,getDBServer(),return RemoteDBInterface.
public interface FactoryServer extends Remote {
public RemoteDBInterface getDBServer() throws RemoteException;
}
public class FactoryServerImpl extends UnicastRemoteObject implements FactoryServer{
public FactoryServerImpl() throws RemoteException{
super();
}
public RemoteDBInterface getDBServer() throws RemoteException{
System.out.println("New Server create");
RemoteDBServer s = new RemoteDBServer();
return (RemoteDBInterface)s;
}
}
if I run this,
FactoryServer f = (FactoryServer)Naming.lookup("....");//find server ,it's ok
but this statement,
RemoteDBInterface rdb = f.getDBServer();
I get ClassCastException.
Anybody can help me how to solve this?
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess you are probably using out dated _Stub files at the client.
 
Jack Yang
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for replying,Sai.I solve it already.
 
Samual Harvey
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jack Yang:
Thank you for replying,Sai.I solve it already.

I am doing the same thing and I am getting Exception in thread "main" java.lang.AbstractMethodError
at suncertify.client.DataAccessFactory.getConnectionChoice(DataAccessFactory.java:
Can you tell what you did to fix the problem.
[ August 15, 2002: Message edited by: Samual Harvey ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic