当前位置:首页 > 开发 > 系统架构 > 架构 > 正文

spring发布RMI服务,多网卡问题

发表于: 2014-04-11   作者:emparadise329   来源:转载   浏览次数:
摘要: 服务器有两个网卡,一个内网,一个外网 Spring xml配置如下: <context:property-placeholder location="classpath:/config/app.properties" /> <!-- 客户端RMI服务 --> <bean id="appPush" class=&qu

服务器有两个网卡,一个内网,一个外网

Spring xml配置如下:

	<context:property-placeholder location="classpath:/config/app.properties" />
	<!-- 客户端RMI服务 -->
	<bean id="appPush" class="cn.com.sinosoft.ebusiness.messagePush.service.server.support.RMIServiceImpl"/>
	<bean id="appPushMsg2Client" class="org.springframework.remoting.rmi.RmiServiceExporter">
		<property name="service" ref="appPush" />
		<!-- 定义服务名 -->
		<property name="serviceName" value="appPushMsg2Client" />
		<property name="serviceInterface" value="cn.com.sinosoft.ebusiness.messagePush.service.server.RMIService" />
		<property name="registryPort" value="${ServicePort}" />
		<property name="registryHost" value="${ServiceRegistryIp}" />
	</bean>

 在app.properties强制spring发布rmi服务注册IP为内网的IP(10.120.20.197),结果发布的时候出现下面异常:

2014-04-11 16:50:05  INFO ClassPathXmlApplicationContext:456  Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@6aaea944: startup date [Fri Apr 11 16:50:05 CST 2014]; root of context hierarchy
2014-04-11 16:50:05  INFO XmlBeanDefinitionReader:315  Loading XML bean definitions from class path resource [config/spring/applicationContext-messagePush.xml]
2014-04-11 16:50:06  INFO PropertyPlaceholderConfigurer:177  Loading properties file from class path resource [config/app.properties]
2014-04-11 16:50:06  INFO DefaultListableBeanFactory:555  Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@44b89233: defining beans [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0,org.springframework.aop.config.internalAutoProxyCreator,appPush,appPushMsg2Client]; root of factory hierarchy
2014-04-11 16:50:06  INFO RmiServiceExporter:328  Looking for RMI registry at port '1099' of host [10.120.20.197]
2014-04-11 16:50:07  INFO DefaultListableBeanFactory:422  Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@44b89233: defining beans [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0,org.springframework.aop.config.internalAutoProxyCreator,appPush,appPushMsg2Client]; root of factory hierarchy
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appPushMsg2Client' defined in class path resource [config/spring/applicationContext-messagePush.xml]: Invocation of init method failed; nested exception is java.rmi.ConnectException: Connection refused to host: 10.120.20.197; nested exception is: 
	java.net.ConnectException: Connection refused: connect
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
	at cn.com.sinosoft.ebusiness.messagePush.App.main(App.java:20)
Caused by: java.rmi.ConnectException: Connection refused to host: 10.120.20.197; nested exception is: 
	java.net.ConnectException: Connection refused: connect
	at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)
	at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
	at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
	at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:341)
	at sun.rmi.registry.RegistryImpl_Stub.list(Unknown Source)
	at org.springframework.remoting.rmi.RmiServiceExporter.testRegistry(RmiServiceExporter.java:420)
	at org.springframework.remoting.rmi.RmiServiceExporter.getRegistry(RmiServiceExporter.java:331)
	at org.springframework.remoting.rmi.RmiServiceExporter.prepare(RmiServiceExporter.java:268)
	at org.springframework.remoting.rmi.RmiServiceExporter.afterPropertiesSet(RmiServiceExporter.java:229)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
	... 12 more
Caused by: java.net.ConnectException: Connection refused: connect
	at java.net.DualStackPlainSocketImpl.connect0(Native Method)
	at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.net.Socket.connect(Socket.java:579)
	at java.net.Socket.connect(Socket.java:528)
	at java.net.Socket.<init>(Socket.java:425)
	at java.net.Socket.<init>(Socket.java:208)
	at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)
	at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:147)
	at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
	... 22 more

如果注释掉这一行

<property name="registryHost" value="${ServiceRegistryIp}" />

 发布的时候从日志上看是外网的IP,现在发布服务的时候要强制绑定到内网的IP上。求解决方法,谢谢!

spring发布RMI服务,多网卡问题

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

编辑推荐
1 、RMI是什么 在 Java 世界里,有一种技术可以实现“跨虚拟机”的调用,它就是 RMI(Remote Method
hello,大家好! 由于工作原因,本篇博文迟迟没有发布上来,在此深表歉意!因宅鸟作为一个老鸟,还有
由于前一段时间发布了几篇关于web程序基于jenkins部署发布的博文,由于是基于svn作为版本库讲解的。
最近客户端报障,提到一个现象,就是邮箱后端数据库Mailbox 角色出现了复制队列持续很高的情况,虽
之前介绍过如何发布RMI服务和调用RMI服务,其实在Spring中为我们提供了更为方便的调用方式。现在介
摘要: “约定优于配置”这是一个相当棒的经验, SOAP服务性能差、基于配置、紧耦合, restful服务
看了《J2EE without EJB》的remote章节,忍不住写点代码试试,看看Spring的实现到底多巧妙。 1.先测
问题现象: 性能测试时,使用的服务器配置了双网卡,windows客户机配置了四网卡,坑爹的配置,内外
1:以前用jmi发布服务,实现分布式的一种方式,远程调用,据说rmi的性能是最好的,维护起来有点麻烦
对于企业应用来说,数据是许多业务的命脉,软件通常是可替换的,但是多年积累的数据是永远不能替换
版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号