I built a sample app based on the 'step-by-step MVC' example and got to the point of the hello.jsp functionality. (Tomcat 5.5.9)
From there, I added a RMI object to the server as follows in the spring-servlet.xml
.....
<bean id="TestObj"
class="dhs.apps.mm.TestObjectImpl">
</bean>
<bean class="org.springframework.remoting.rmi.RmiService Exporter">
<property name="service">
<ref bean="TestObj"/>
</property>
<property name="serviceName">
<value>TestObjectService</value>
</property>
<property name="serviceInterface">
<value>dhs.apps.mm.TestObject</value>
</property>
</bean>......
......
When Tomcat starts, it reports the presence of the new Beans:
......
......
INFO [org.springframework.remoting.rmi.RmiServiceExporte r] - Looking for RMI registry at port '1099'
2005-10-06 08:28:24,839 WARN [org.springframework.remoting.rmi.RmiServiceExporte r] - Could not detect RMI registry - creating new one
2005-10-06 08:28:24,839 INFO [org.springframework.remoting.rmi.RmiServiceExporte r] - RMI object 'TestObjectService' is an RMI invoker
2005-10-06 08:28:25,058 INFO [org.springframework.aop.framework.DefaultAopProxyF actory] - CGLIB2 available: proxyTargetClass feature enabled
2005-10-06 08:28:25,089 INFO [org.springframework.remoting.rmi.RmiServiceExporte r] - Binding RMI service 'TestObjectService' to registry at port '1099'
.....
.....
So now, it appears that the service is ready to be used????
(Checking the server's network ports, port 1099 is listening.)
From the client perspective, I have a Swing app (java main()) that starts the Spring context, in the same fashon as the Rich Client sample.
During the Application startup, it hesitates breifly as it starts the contexts and brings the obejcts into the JVM
.....
.....
INFO: Creating shared instance of singleton bean 'TestRemoteObject'
Oct 6, 2005 8:29:24 AM org.springframework.remoting.rmi.RmiClientIntercep tor prepare
INFO: RMI stub [rmi://172.29.4.161/TestObjectService] is an RMI invoker
Oct 6, 2005 8:29:25 AM org.springframework.aop.framework.DefaultAopProxyF actory <clinit>
INFO: CGLIB2 available: proxyTargetClass feature enabled......
......
(If the Tomcat server is down at this point, the startup of the client app will get a timeout exception in RMI.)
Then, in the client application, when it comes time to use the remote Object,
......
......Code:String TEST_OBJ_REMOTE = "TestRemoteObject"; TestObject tRemBeanObj = (TestObject)dhs.framework.application.Application.services().getBean(TEST_OBJ_REMOTE, dhs.apps.mm.TestObject.class); tRemBeanObj.setObjectName("RemoteObject");
......
the exception occurs: (After about 20 seconds..)
.....
.....
Cannot connect to remote service [rmi://172.29.4.161/TestObjectService]; nested exception is java.rmi.ConnectException: Connection refused to host: 172.29.4.161; nested exception is:
java.net.ConnectException: Connection timed out: connect
org.springframework.remoting.RemoteConnectFailureE xception: Cannot connect to remote service [rmi://172.29.4.161/TestObjectService]; nested exception is java.rmi.ConnectException: Connection refused to host: 172.29.4.161; nested exception is:
java.net.ConnectException: Connection timed out: connect
java.rmi.ConnectException: Connection refused to host: 172.29.4.161; nested exception is:
java.net.ConnectException: Connection timed out: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknow n Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection( Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unk nown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at org.springframework.remoting.rmi.RmiInvocationWrap per_Stub.invoke(Unknown Source)
at org.springframework.remoting.rmi.RmiClientIntercep tor.doInvoke(RmiClientInterceptor.java:347)
at org.springframework.remoting.rmi.RmiClientIntercep tor.doInvoke(RmiClientInterceptor.java:294)
at org.springframework.remoting.rmi.RmiClientIntercep tor.invoke(RmiClientInterceptor.java:209)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :144)
at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:174)
at $Proxy0.setObjectName(Unknown Source)
at dhs.apps.mm.Mm.start(Mm.java:88)
at dhs.framework.application.ApplicationLauncher.laun chDhsApp(ApplicationLauncher.java:174)
at dhs.framework.application.ApplicationLauncher.<ini t>(ApplicationLauncher.java:103)
at dhs.apps.mm.Mm.main(Mm.java:217)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.cre ateSocket(Unknown Source)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.cre ateSocket(Unknown Source)
... 15 more.....
....
I am not sure what else is needed in the Server to make RMI 'available'.
Thanks for any advice.
Bruce


Reply With Quote