Reputation: 535
I have two peers to connect though RMI. At the RMI server side I am using Spring inerfaces (http://www.studytrails.com/frameworks/spring/spring-remoting-rmi.jsp). At the RMI client side I need to start it with out know if the server is UP. So if I use spring my client does not start and I have connection refused exception.
<bean class="org.springframework.remoting.rmi.RmiServiceExporter">
<property name="serviceName" value="RestoreRMIService" />
<property name="serviceInterface" value="br.com.eb.service.iscsi.RestoreService" />
<property name="service" ref="restoreService" />
</bean>
So I tried to use pure java RMI on the client side (http://www.javacoffeebreak.com/articles/javarmi/javarmi.html). But I am getting ClassCastException: com.sun.proxy.$Proxy73 cannot be cast to br.com.eb.service.iscsi.RestoreService. I beliave because I don't have stubs from my RMI server.
I wnat pure java RMI on the client side because I need to be able to restart the server side.
protected void connectRMI() {
if (!rmiConected) {
try {
Registry registry = LocateRegistry.getRegistry(1099);
serviceRestore = (RestoreService) registry.lookup("RestoreRMIService");
// serviceRestore = (RestoreService) Naming.lookup("rmi://127.0.0.1/RestoreRMIService");
rmiConected = true;
} catch (ConnectException ce) {
System.err.println("Error: server not started");
rmiConected = false;
} catch (ConnectIOException cioe) {
System.err.println("Error: Cannot connect to server at 127.0.0.1");
rmiConected = false;
} catch (Exception e) {
e.printStackTrace();
}
}
}
Upvotes: 0
Views: 823
Reputation: 310860
You don't need to switch RMI implementations just to solve a 'connection refused' exception.
Java RMI gets 'connection refused' exceptions too.
Java RMI and Spring RMI do not interoperate.
Your question doesnt make sense.
Upvotes: 2