[英]Spring RMI server and pure java RMI client
I have two peers to connect though RMI. 我有两个同行通过RMI连接。 At the RMI server side I am using Spring inerfaces ( http://www.studytrails.com/frameworks/spring/spring-remoting-rmi.jsp ).
在RMI服务器端,我正在使用Spring接口( 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.
在RMI客户端,我需要在不知道服务器是否已启动的情况下启动它。 So if I use spring my client does not start and I have connection refused exception.
因此,如果我使用spring,则我的客户端无法启动,并且连接被拒绝。
<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 ). 因此,我尝试在客户端上使用纯Java RMI( 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.
但是我收到ClassCastException:com.sun.proxy。$ Proxy73无法转换为br.com.eb.service.iscsi.RestoreService。 I beliave because I don't have stubs from my RMI server.
我相信,因为我的RMI服务器没有存根。
I wnat pure java RMI on the client side because I need to be able to restart the server side. 我在客户端拥有纯Java RMI,因为我需要能够重新启动服务器端。
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();
}
}
}
Java RMI and Spring RMI do not interoperate. Java RMI和Spring RMI无法互操作。
Your question doesnt make sense. 您的问题没有道理。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.