【问题标题】:Externally access Spring Java RMI service in cloudbeescloudbees中外部访问Spring Java RMI服务
【发布时间】:2013-05-02 04:49:07
【问题描述】:

我已成功将 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 端点吗?

谢谢!

【问题讨论】:

    标签: java spring rmi cloudbees


    【解决方案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

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-06
    • 2016-06-20
    • 2019-11-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多