I have deployed a spring rmi web application(WAR file) to the cloudbees successfully. This application contains simple RMI service called "greetingRmiService" which return a String contains a greeting message. Here is the server log part that says it deployed my rmi service successfully.
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]]]]
Now I want to create a client app in my local pc to connect with this service and call that service. My client is a simple maven application. Here is the clients' spring configuration 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>
Client main method:
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"));
}
But this is not working and it gives a connection timeout exception. I have used endpoint 10.119.1.56:1099 to connect with the server. Is it the correct rmi endpoint i should use when i connect to the cloudbees server externally?
Thanks!
For RMI to work correctly you will have to tunnel over http(s) to go via the proxy/routing layer.
You can read more about tunnelling:
For spring applications: http://static.springsource.org/spring-integration/docs/2.0.0.RELEASE/reference/html/httpinvoker.html