if (getServiceInterface() != null && Remote.class.isAssignableFrom(getServiceInterface())) {
try {
stub = PortableRemoteObject.narrow(stub, getServiceInterface());
}
catch (ClassCastException ex) {
throw new RemoteLookupFailureException(
"Could not narrow RMI stub to service interface [" + getServiceInterface().getName() + "]", ex);
}
}
if (!(stub instanceof Remote)) {
throw new RemoteLookupFailureException("Located RMI stub of class [" + stub.getClass().getName() +
"], with JNDI name [" + getJndiName() + "], does not implement interface [java.rmi.Remote]");
}
return (Remote) stub;
}