Announcement Announcement Module
Collapse
No announcement yet.
Request a Tomcat / RMI / Spring based example Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Request a Tomcat / RMI / Spring based example

    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 = &#40;TestObject&#41;dhs.framework.application.Application.services&#40;&#41;.getBean&#40;TEST_OBJ_REMOTE, dhs.apps.mm.TestObject.class&#41;;
    	   
    tRemBeanObj.setObjectName&#40;"RemoteObject"&#41;;
    ......
    ......

    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

  • #2
    I'm also interested in any comments on this post.

    my system environment is :Tomcat 5.0.28+windows xp+Java1.5, and I turn off windows xp firewall. when telnet localhost port, it works. but when i call RMI service interface, client application throws timeout exception.

    if anybody has idea about the question.

    thanks.
    Last edited by greateWei; Oct 30th, 2005, 07:11 AM.

    Comment


    • #3
      Originally posted by Bruce_Becker
      ...
      I am not sure what else is needed in the Server to make RMI 'available'.

      Thanks for any advice.

      Bruce
      if your tomcat install path include blank, try it .

      There is a bug in the JDK which makes RMI fail if Tomcat is installed in directory containing spaces (e.g. C:\Program Files\Apache Group\Jakarta Tomcat 5.0). This bug won't be fixed, so you can only workaround it.

      The installation should have checked the folder name for you and promted you to reinstall Tomcat. If you missed that or renamed the folder after you installed KIM, follow the seme advice now: reinstall Tomcat in a folder (using underscores instead of spaces for example) or just rename folders needed so that the full path contains no spaces. Then reinstall KIM too and point it to the new loacation when asked for Tomcat server, or to skip the new install just manually edit your start/stop Tomcat bat/sh files in %KIM_Platform_Home%/bin directory where this path is used.

      For more details refer to:

      http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4543
      http://bugs.sun.com/bugdatabase/view...bug_id=4496398
      http://bugs.sun.com/bugdatabase/view...bug_id=4273532

      Comment

      Working...
      X