发表于: 2016-12-23 20:33:19
2 2004
一.今天完成的事情
1.java RMI框架(远程方法调用):http://haolloyin.blog.51cto.com/1177454/332426/
2.Spring与RMI的集成,实现远程调用:http://blog.csdn.net/shirdrn/article/details/6359254
RMI:远程方法调用(Remote Method Invocation)。能够让在某个java虚拟机上的对象像调用本地对象一样调用另一个java 虚拟机中的对象上的方法。
本质:RMI的本质就是实现在不同JVM之间的调用,它的实现方法就是在两个JVM中各开一个Stub和Skeleton,二者通过socket通信来实现参数和返回值的传递。
局限性:RMI对服务器的IP地址和端口依赖很紧密,但是在开发的时候不知道将来的服务器IP和端口如何,但是客户端程序依赖这个IP和端口。这也是RMI的局限性之一。这个问题有两种解决途径:一是通过DNS来解决,二是通过封装将IP暴露到程序代码之外。RMI的局限性之二是RMI是Java语言的远程调用,两端的程序语言必须是Java实现,对于不同语言间的通讯可以考虑用Web Service或者公用对象请求代理体系(CORBA)来实现。
二.明天的计划
1.将原有学员系统中Service中拆分出来,变成一个RMI的Service。
三.遇到的问题
1.在Spring与RMI集成时,:server.xml的配置
<bean id="accountService" class="com.wangsx.task4_Tiles.test.MobileAccountServiceImpl" />
<bean id="serviceExporter" class="org.springframework.remoting.rmi.RmiServiceExporter">
<property name="serviceName" value="MobileAccountService" />
<property name="service" ref="accountService" />
<property name="serviceInterface"
value="com.wangsx.task4_Tiles.test.AccountService" />
<property name="registryPort" value="8080" />
<property name="servicePort" value="8088" />
</bean>
public class RmiServer {
public static void main(String[] args) throws InterruptedException {
new ClassPathXmlApplicationContext("com/wangsx/task4_Tiles/test/server.xml");
}
}
spring与RMI整合,当启动RmiServer时报错:java.rmi.ConnectException: Connection refused to host: 10.30.85.242; nested exception is:java.net.ConnectException: Connection refused: connect???
server端依然报错:但我执行两次client端输出正常结果:Your mobile number is 13800138000,protocol type is 5
(郁闷死拉。。。)
我把pom.xml中的内容全部删除,只留下spring-core和spring-context, 报错消失。这样我就能判断是jar包的问题,但怎样排查哪个jar包出问题呢???
四.收获
1.
评论