Spring RMI注意问题
来源:互联网 发布:淘宝特价群怎么赚钱 编辑:程序博客网 时间:2024/06/09 21:22
转载自: http://yangwencan2002.iteye.com/blog/284249
RMI问题1:
用 ./shutdown.sh 关闭 rmi 服务器的 tomcat ,然后 ./startup.sh 启动,客户端连接总是会导致如下错误:
org.springframework.remoting.RemoteLookupFailureException: Lookup of RMI stub failed; nested exception is java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.io.EOFException
分析:
The cause of the problem is the fact that Spring creates an RMIRegistry with the classloader of the server webapp. Then, when restarting the server, the RMIRegistry is not shut down. After the restart the Registry keeps its references to the old Stubs which do not exist anymore.
There are two solutions:
1) Start the rmiregistry in a seperate process without the classpath of the server app.
2) (better approach) Let spring start the RMIRegistry throu RmiRegistryFactoryBean, which shuts it down correctly.
解决:
将服务器中的 spring 配置代码,如下:
RMI问题2:
RMI 服务器重启,总是会出现客户端连接拒绝的问题。
分析:
服务器重启会影响到客户端,说明客户端有保存着重启之前的服务器连接相关记录。经研究发现,客户端有缓存,所以只要刷新缓存即可解决问题。
解决:
在客户端连接代码中增加代码:
RMI问题3:
Spring RMI会占用两个端口?
分析:
Spring RMI 有两个端口,一个是注册端口(默认为1099),还有一个是数据传输端口,如果不指定,数据传输端口是随机分配的。
解决:
在xml配置时,配置servicePort
RMI问题1:
用 ./shutdown.sh 关闭 rmi 服务器的 tomcat ,然后 ./startup.sh 启动,客户端连接总是会导致如下错误:
org.springframework.remoting.RemoteLookupFailureException: Lookup of RMI stub failed; nested exception is java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.io.EOFException
分析:
The cause of the problem is the fact that Spring creates an RMIRegistry with the classloader of the server webapp. Then, when restarting the server, the RMIRegistry is not shut down. After the restart the Registry keeps its references to the old Stubs which do not exist anymore.
There are two solutions:
1) Start the rmiregistry in a seperate process without the classpath of the server app.
2) (better approach) Let spring start the RMIRegistry throu RmiRegistryFactoryBean, which shuts it down correctly.
解决:
将服务器中的 spring 配置代码,如下:
<bean id = "rmiService" class = "org.springframework.remoting.rmi.RmiServiceExporter" > <property name = "serviceName" value = "service1" /> <property name = "service" ref = "servicebean" /> <property name = "serviceInterface" value = "com.Iservice" /> <property name = "registryPort" value = "1099" /></bean >替换为:
<bean id="registry" class="org.springframework.remoting.rmi.RmiRegistryFactoryBean"> <property name="port" value="1099"/></bean><bean id = "rmiService" class = "org.springframework.remoting.rmi.RmiServiceExporter" > <property name = "serviceName" value = "service1" /> <property name = "service" ref = "servicebean" /> <property name = "serviceInterface" value = "com.Iservice" /> <property name="registry" ref="registry"/></bean >
RMI问题2:
RMI 服务器重启,总是会出现客户端连接拒绝的问题。
分析:
服务器重启会影响到客户端,说明客户端有保存着重启之前的服务器连接相关记录。经研究发现,客户端有缓存,所以只要刷新缓存即可解决问题。
解决:
在客户端连接代码中增加代码:
RmiProxyFactoryBean factory= new RmiProxyFactoryBean();factory.setServiceInterface(IService. class );factory.setServiceUrl(url);//解决重启 rmi 的服务器后会出现拒绝连接或找不到服务对象的错误factory.setLookupStubOnStartup(false);//不在容器启动的时候创建与Server端的连接factory.setRefreshStubOnConnectFailure(true);//表示是否连接出错时自动重连factory.afterPropertiesSet();IService service=( IService)factory.getObject();
RMI问题3:
Spring RMI会占用两个端口?
分析:
Spring RMI 有两个端口,一个是注册端口(默认为1099),还有一个是数据传输端口,如果不指定,数据传输端口是随机分配的。
解决:
在xml配置时,配置servicePort
<bean id="registry" class="org.springframework.remoting.rmi.RmiRegistryFactoryBean"> <property name="port" value="1099"/></bean><bean id = "rmiService" class = "org.springframework.remoting.rmi.RmiServiceExporter" > <property name = "serviceName" value = "service1" /> <property name = "service" ref = "servicebean" /> <property name = "serviceInterface" value = "com.Iservice" /> <property name="registry" ref="registry"/> <property name="servicePort" value="1199" /></bean >
0 0
- Spring RMI注意问题
- Spring RMI注意问题
- JBOSS实现RMI时注意的问题
- JBOSS实现RMI时注意的问题
- 基于spring的rmi缓存问题
- Spring Boot 注意问题
- spring RMI
- Spring rmi
- rmi spring
- Spring RMI
- spring rmi
- Spring RMI
- Spring - RMI
- spring rmi
- RMI 问题
- spring的几个注意问题
- mybatis spring集成注意问题
- spring+jersery集成注意问题
- 关于数据库的SQL入门,转载
- gradle 笔记 (多样化build app)
- Foundation框架的简单介绍
- Qt学习之路(10): Meta-Object系统
- mysql查询优化需要注意的20点?
- Spring RMI注意问题
- Hibernate的反向工程
- ListView内存优化
- PgSQL · 答疑解惑 · PostgreSQL 用户组权限管理
- 十字链表的实现C++
- git服务器的建立——Git折腾小记(推荐阅读)
- 南大软院21天大神养成计划-第1天
- 输入流,输出流
- java中stringBuilder的用法