浏览 11998 次
锁定老帖子 主题:spring 的rmi 问题
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2007-01-11
把服务端部署在windows下,客户端在(fedora 4)下,远程调用没有问题 把服务端和客户端分别部署在两台linux机器下(fedora)就会报错 错误内容是: org.springframework.remoting.RemoteConnectFailureException: Cannot connect to remote service [rmi://192.168.0.106:1199/ItemRetag]; nested exception is java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is: java.net.ConnectException: Connection refused java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is: java.net.ConnectException: Connection refused at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:574) at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185) at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:171) at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:94) at org.springframework.remoting.rmi.RmiInvocationWrapper_Stub.invoke(Unknown Source) at org.springframework.remoting.rmi.RmiClientInterceptor.doInvoke(RmiClientInterceptor.java:347) at org.springframework.remoting.rmi.RmiClientInterceptor.doInvoke(RmiClientInterceptor.java:294) at org.springframework.remoting.rmi.RmiClientInterceptor.invoke(RmiClientInterceptor.java:209) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176) 我不知道为什么还会连127.0.0.1这个地址? 我的配置文件是这样的: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean class="org.springframework.remoting.rmi.RmiServiceExporter"> <property name="serviceName" value="ItemRetag" /> <property name="service" ref="itemRetagService" /> <property name="serviceInterface" value="com.souchang.highfly.registeritem.service.ItemTagger" /> <property name="registryPort" value="1199" /> </bean> <bean id="itemRetagService" class="com.souchang.highfly.registeritem.service.impl.ItemTaggerImpl"> </bean> </beans> <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="itemRetagService" class="org.springframework.remoting.rmi.RmiProxyFactoryBean"> <property name="serviceUrl" value="rmi://192.168.0.106:1199/ItemRetag"/> <property name="serviceInterface" value="com.souchang.highfly.registeritem.service.ItemTagger"/> </bean> </beans> 哪位兄弟给点提示吧?实在搞不定了 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2007-01-11
搞定了
服务端启动的时候需要这样一个参数 <sysproperty key="java.rmi.server.hostname" value="192.168.0.106"/> 还不知道为什么 ? |
|
返回顶楼 | |
发表时间:2007-01-11
The java.rmi.server.hostname property specifies the host name or address to put in the stubs for remote objects exported in this Java virtual machine. This value is the host name or address used by clients when they attempt to communicate remote method invocations. By default, the RMI implementation uses the server's IP address as indicated by the java.net.InetAddress.getLocalHost API. However, sometimes, this address is not appropriate for all clients and a fully qualified host name would be more effective. To ensure that RMI uses a host name (or IP address) for the server that is routable from all potential clients, set the java.rmi.server.hostname property.
|
|
返回顶楼 | |
发表时间:2007-01-12
因为对方的服务器有两个ip地址,一个127.0.0.1,一个192.168.0.106,而服务器上的rmi服务端默认取得的是127.0.0.1,所以需要明确指出使用哪个ip,我以前因为这个问题,折腾了一天:( |
|
返回顶楼 | |
发表时间:2007-01-15
By default, the RMI implementation uses the server's IP address as indicated by the java.net.InetAddress.getLocalHost API.
主要是这个原因java.net.InetAddress.getLocalHost取本机ip的时候,在windows下取到的是正确的ip,而在linux下取到的是127.0.0.1(fedora4,as3下都是这样的) |
|
返回顶楼 | |
发表时间:2007-01-25
redack 写道 By default, the RMI implementation uses the server's IP address as indicated by the java.net.InetAddress.getLocalHost API.
主要是这个原因java.net.InetAddress.getLocalHost取本机ip的时候,在windows下取到的是正确的ip,而在linux下取到的是127.0.0.1(fedora4,as3下都是这样的) 是这样的,执行一下这句话: System.out.println(InetAddress.getLocalHost()); 看他返回的地址是多少,如果返回的不是你jnid properties里面的值,就应该是出问题的, 我也碰到了这个问题。 我的处理方法是,修改了/etc/hosts文件,增加了一句话: 10.0.12.42 just4love 前面是我的ip地址,后面是我的hostname。 |
|
返回顶楼 | |