サーバ:
Registry registry = LocateRegistry.createRegistry(1099);
InventoryInterface Inventory = new Inventory(registry);
registry.bind("Inventory", Inventory);
クライアント:
Registry registry = LocateRegistry.getRegistry(1099);
InventoryInterface inventory = (InventoryInterface) registry.lookup("Inventory");
String product_id = inventory.newProduct();
ProductFacade product_1 = (ProductFacade) registry.lookup(product_id);
問題は、キャスト時に例外が発生することです。この場合、次の場所で発生します。ProductFacade product_1 = (ProductFacade) registry.lookup(product_id);
例外:
Exception in thread "main" java.lang.ClassCastException: com.sun.proxy.$Proxy2 cannot be cast to rmi.ProductFacade