Server:
Registry registry = LocateRegistry.createRegistry(1099);
InventoryInterface Inventory = new Inventory(registry);
registry.bind("Inventory", Inventory);
Client:
Registry registry = LocateRegistry.getRegistry(1099);
InventoryInterface inventory = (InventoryInterface) registry.lookup("Inventory");
String product_id = inventory.newProduct();
ProductFacade product_1 = (ProductFacade) registry.lookup(product_id);
The Problem is the exception happens at the casting, in this case it happens at: ProductFacade product_1 = (ProductFacade) registry.lookup(product_id);
Exception:
Exception in thread "main" java.lang.ClassCastException: com.sun.proxy.$Proxy2 cannot be cast to rmi.ProductFacade
It can be about how you bind it. For example, if ProductFacade implements InventoryInterface you might need to cast it as InventoryInterface instead of ProductFacade.