0

我已成功将 spring rmi Web 应用程序(WAR 文件)部署到 cloudbees。此应用程序包含名为“greetingRmiService”的简单 RMI 服务,它返回一个包含问候消息的字符串。这是服务器日志部分,它说它成功部署了我的 rmi 服务。

INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@79d9cd24: defining beans [registry,greetingService,org.springframework.remoting.rmi.RmiServiceExporter#0]; root of factory hierarchy
May 02, 2013 4:06:20 AM org.springframework.remoting.rmi.RmiRegistryFactoryBean getRegistry
INFO: Looking for RMI registry at port '1099'
May 02, 2013 4:06:35 AM org.springframework.remoting.rmi.RmiRegistryFactoryBean getRegistry
INFO: Could not detect RMI registry - creating new one
May 02, 2013 4:06:35 AM org.springframework.remoting.rmi.RmiServiceExporter prepare
INFO: Binding service 'greetingRmiService' to RMI registry: RegistryImpl[UnicastServerRef [liveRef: [endpoint:[10.119.1.56:1099](local),objID:[0:0:0, 0]]]]

现在我想在我的本地电脑上创建一个客户端应用程序来连接这个服务并调用那个服务。我的客户端是一个简单的 Maven 应用程序。这是客户的spring配置bean。

<bean id="greetingService" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
<property name="serviceUrl" value="rmi://10.119.1.56:1099/greetingRmiService"/>
<property name="serviceInterface" value="com.main.GreetingService"/>
</bean>

客户端主要方法:

public static void main( String[] args )
{

ApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:com/config/SpringConfigurationBean.xml");
GreetingService service = (GreetingService) ctx.getBean("greetingService");
System.out.println(service.sayHello("Lahiru"));
}

但这不起作用,它给出了连接超时异常。我已使用端点 10.119.1.56:1099 与服务器连接。当我从外部连接到 cloudbees 服务器时,我应该使用正确的 rmi 端点吗?

谢谢!

4

1 回答 1

1

要使 RMI 正常工作,您必须通过 http(s) 隧道通过代理/路由层。

您可以阅读有关隧道的更多信息:

http://www.java-forums.org/blogs/rmi/730-what-http-tunneling-how-make-rmi-calls-across-firewalls.html

对于弹簧应用程序: http ://static.springsource.org/spring-integration/docs/2.0.0.RELEASE/reference/html/httpinvoker.html

于 2013-05-06T07:04:35.370 回答