发布个rmi服务居然出现如下:
17.05.2009 10:19:50 [main] INFO org.springframework.remoting.rmi.RmiServiceExporter - Looking for RMI registry at port '1099'
17.05.2009 10:19:54 [main] DEBUG org.springframework.remoting.rmi.RmiServiceExporter - RMI registry access threw exception
java.rmi.ConnectException: Connection refused to host: 172.18.7.235; nested exception is:
java.net.ConnectException: Connection refused: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:601)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322)
at sun.rmi.registry.RegistryImpl_Stub.list(Unknown Source)
at org.springframework.remoting.rmi.RmiServiceExporter.testRegistry(RmiServiceExporter.java:411)
at org.springframework.remoting.rmi.RmiServiceExporter.getRegistry(RmiServiceExporter.java:391)
at org.springframework.remoting.rmi.RmiServiceExporter.getRegistry(RmiServiceExporter.java:370)
at org.springframework.remoting.rmi.RmiServiceExporter.getRegistry(RmiServiceExporter.java:331)
at org.springframework.remoting.rmi.RmiServiceExporter.prepare(RmiServiceExporter.java:263)
at org.springframework.remoting.rmi.RmiServiceExporter.afterPropertiesSet(RmiServiceExporter.java:227)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
at cn.edu.hust.mes.webservice.CallWebServices.<clinit>(CallWebServices.java:31)
at cn.edu.hust.mes.opcapp.OpcApplication.main(OpcApplication.java:15)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:519)
at java.net.Socket.connect(Socket.java:469)
at java.net.Socket.<init>(Socket.java:366)
at java.net.Socket.<init>(Socket.java:180)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595)
28 more
17.05.2009 10:19:54 [main] INFO org.springframework.remoting.rmi.RmiServiceExporter - Could not detect RMI registry - creating new one
17.05.2009 10:19:54 [main] DEBUG org.springframework.remoting.rmi.RmiServiceExporter - RMI service [cn.edu.hust.mes.webservice.OpcPlcRmiServiceImpl@dac21] is an RMI invoker
17.05.2009 10:19:54 [main] DEBUG org.springframework.aop.framework.JdkDynamicAopProxy - Creating JDK dynamic proxy: target source is SingletonTargetSource for target object [cn.edu.hust.mes.webservice.OpcPlcRmiServiceImpl@dac21]
17.05.2009 10:19:54 [main] INFO org.springframework.remoting.rmi.RmiServiceExporter - Binding service 'opcManager' to RMI registry: RegistryImpl[UnicastServerRef [liveRef: [endpoint:[172.18.7.235:1099](local),objID:[0:0:0, 0]]]]
--------------------------------------------------
可见:Binding service 'opcManager' to RMI registry: RegistryImpl[UnicastServerRef [liveRef: [endpoint:[172.18.7.235:1099](local),objID:[0:0:0, 0]]]]
RMI其实发布成功了...
为什么开始有错呢?
查看源代码发现:其实是Spring的Debug log
他会先看有没rmi注册
org.springframework.remoting.rmi.RmiServiceExporter.testRegistry(RmiServiceExporter.java:411)
没有log下再
Could not detect RMI registry - creating new one
所以屏蔽该Log4j配置文件中加如:
log4j.logger.org.springframework.remoting.rmi.RmiServiceExporter=INFO