AlanRubinoff
AlanRubinoff

Reputation: 385

com.sun.proxy.$Proxy1 cannot be cast to

GameV1 game;

  public void connect() {
    connect("//localhost/Game");
    if (getServer() != null) {
        game= (GameV1) getServer();

    }

}

this method "connect("//localhost/Game");" just sets the server on the upperclase which then is casted to GameV1 Game=interface GameV1=concrete class with implements Game

if (getServer() != null) this returns true but i get this error when cast com.sun.proxy.$Proxy1 cannot be cast to GameV1

Upvotes: 0

Views: 9745

Answers (1)

Robin Green
Robin Green

Reputation: 33083

With a RMI remote object you can't cast to the concrete class. You have to cast to the remote interface.

Upvotes: 7

Related Questions