Announcement Announcement Module
Collapse
No announcement yet.
Spring RMI Remoting -Plain RMI Client Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring RMI Remoting -Plain RMI Client

    Hello,

    I am having difficulty in access a spring managed RMI service running on a remote server from a plain RMI client running on my local machine.

    I have no problems with the export and service binding as you can see from the following logs

    [main] (RmiServiceExporter.java:322) INFO org.springframework.remoting.rmi.RmiServiceExporte r - Looking for RMI registry at port '1199'
    4562 [main] (RmiBasedExporter.java:59) DEBUG org.springframework.remoting.rmi.RmiServiceExporte r - RMI service [com.mi.webmark.ftp.dpac.service.impl.DataConsolida tionServiceImpl@3a1834] is an RMI invoker
    4594 [main] (RmiServiceExporter.java:236) INFO org.springframework.remoting.rmi.RmiServiceExporte r - Binding RMI service 'ConsolidationService' to registry at port '1199'

    But when my plain RMI client running on my local machine tries to access the RMI service running on the server, I am getting the following expection after I appended classpath with spring-remoting.jar

    java.lang.ClassCastException: org.springframework.remoting.rmi.RmiInvocationWrap per_Stub

    Now my question is : why am I getting org.springframework.remoting.rmi.RmiInvocationWrap per_Stub
    when I am expecting my service interface?

    API documention for org.springframework.remoting.rmi.RmiServiceExporte r
    says the following

    <quote>
    RMI exporter that exposes the specified service as RMI object with the specified name. Such services can be accessed via plain RMI or via RmiProxyFactoryBean. Also supports exposing any non-RMI service via RMI invokers, to be accessed via RmiClientInterceptor/RmiProxyFactoryBean's automatic detection of such invokers
    </quote>


    Am I missing something or Do I need a spring managed client app to access the spring managed RMI service?

    Quick response will be appreciated.

  • #2
    If the exported interface is a regular RMI interface you should be able to access it with a plain RMI client. If it is a "normal" interface you need RmiClientInterceptor or RmiProxyFactoryBean on the client.

    An RMI interface is expected to extend the java.rmi.Remote interface and each method has to declare throwing an RmiException.

    Regards,
    Andreas

    Comment


    • #3
      Many thanks for your quick reply. Really appreciated.

      I have tried it before and again on your suggestion but I am getting the following runtime expection as before when I extend java.rmi.Remote interface in my service interface and change remote methods signature to throw RemoteException.

      Can you help me on this please?


      org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'org.springframework.remoting.rmi.RmiServiceExport er' defined in class path resource [com/mi/webmark/ftp/dpac/remoting/config/remoting-appContext.xml]: Initialization of bean failed; nested exception is java.rmi.StubNotFoundException: Stub class not found: $Proxy2_Stub; nested exception is:
      java.lang.ClassNotFoundException: $Proxy2_Stub
      java.rmi.StubNotFoundException: Stub class not found: $Proxy2_Stub; nested exception is:
      java.lang.ClassNotFoundException: $Proxy2_Stub
      at sun.rmi.server.RemoteProxy.getStub(RemoteProxy.jav a:98)
      at sun.rmi.server.RemoteProxy.getStub(RemoteProxy.jav a:55)
      at sun.rmi.server.UnicastServerRef.setSkeleton(Unicas tServerRef.java:179)
      at sun.rmi.server.UnicastServerRef.exportObject(Unica stServerRef.java:142)
      at sun.rmi.server.UnicastServerRef.exportObject(Unica stServerRef.java:129)
      at java.rmi.server.UnicastRemoteObject.exportObject(U nicastRemoteObject.java:275)
      at java.rmi.server.UnicastRemoteObject.exportObject(U nicastRemoteObject.java:178)
      at org.springframework.remoting.rmi.RmiServiceExporte r.afterPropertiesSet(RmiServiceExporter.java:244)
      at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1059)
      at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:363)
      at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:226)
      at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:147)
      at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:275)
      at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:320)
      at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:87)
      at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:72)
      at org.springframework.test.AbstractSpringContextTest s.loadContextLocations(AbstractSpringContextTests. java:121)
      at org.springframework.test.AbstractDependencyInjecti onSpringContextTests.loadContextLocations(Abstract DependencyInjectionSpringContextTests.java:210)
      at org.springframework.test.AbstractSpringContextTest s.getContext(AbstractSpringContextTests.java:101)
      at org.springframework.test.AbstractDependencyInjecti onSpringContextTests.setUp(AbstractDependencyInjec tionSpringContextTests.java:178)
      at junit.framework.TestCase.runBare(TestCase.java:125 )
      at junit.framework.TestResult$1.protect(TestResult.ja va:106)
      at junit.framework.TestResult.runProtected(TestResult .java:124)
      at junit.framework.TestResult.run(TestResult.java:109 )
      at junit.framework.TestCase.run(TestCase.java:118)
      at junit.framework.TestSuite.runTest(TestSuite.java:2 08)
      at junit.framework.TestSuite.run(TestSuite.java:203)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:478)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:344)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:196)
      Caused by: java.lang.ClassNotFoundException: $Proxy2_Stub
      at java.net.URLClassLoader$1.run(URLClassLoader.java: 199)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.j ava:187)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:2 89)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:274)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:2 35)
      at sun.rmi.server.RemoteProxy.loadClassFromClass(Remo teProxy.java:191)
      at sun.rmi.server.RemoteProxy.getStub(RemoteProxy.jav a:93)
      ... 29 more

      Comment


      • #4
        Can you try exporting the bean without spring? Can you access the bean in this case?

        Regards,
        Andreas

        Comment


        • #5
          Thanks Andreas,

          Can you explain more " exporting bean without spring". Do you mean writing a plain RMI Service and registering with RMI registry?

          Regards

          Comment


          • #6
            Exactly. Just to rule out that the problem is actually an RMI-problem. If the bean can be exported by conventional ways it *should* also work with Spring. If it doesn't, well, then there is still something to analyze ;-)

            Regards,
            Andreas

            Comment


            • #7
              Thanks Andreas,

              Perhaps, I failed to mention earlier. The RMI service works perfectly with spring managed client. That means when I access the service using a spring managed client running on my local machine it worked fine. That I think proves that RMI service is fine- Do you agree?

              Regards

              Comment


              • #8
                There still exists the possibility that the bean in question is not recognized as real Remote bean, thus handled specially by Spring. In that case the non-Spring-client cannot handle it.

                One question here: Does the bean class extend UnicastRemoteObject?

                Regards,
                Andreas

                P.S.: Is there a reason you do not want to use a Spring-managed client?

                Comment


                • #9
                  Thanks for your reply.

                  1) No the bean class not extending UnicastRemoteObject

                  2) We are using RMI as an integration mechanism between Oracle Worflkow server and Oracle application Server.

                  Do you think extending UnicastRemoteObject calss would solev the problem?

                  Regards

                  Comment


                  • #10
                    Originally posted by skonathala
                    Do you think extending UnicastRemoteObject calss would solev the problem?
                    I would think so.

                    Regards,
                    Andreas

                    Comment


                    • #11
                      exporting iiop service using (JndiRmiServiceExporter)

                      Hi All,

                      I am Developing a server using spring. I want to export my services on IIOP using JndiRmiServiceExporter. For exporting my service the context xml file is like this

                      <bean id="accountService" class="core.security.service.impl.AccountServiceIm pl">
                      <property name="string">
                      <value>initial string value</value>
                      </property>
                      </bean>

                      <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
                      <property name="environment">
                      <props>
                      <prop key="java.naming.factory.initial">com.sun.jndi.cos naming.CNCtxFactory</prop>
                      <prop key="java.naming.provider.url">corbaloc:iiop:gurms ingh:12026/StandardNS/NameServer-POA/_root</prop>
                      </props>
                      </property>
                      </bean>

                      <bean id="iiopSachin" class="org.springframework.remoting.rmi.JndiRmiSer viceExporter">
                      <property name="jndiTemplate">
                      <ref bean="jndiTemplate"/>
                      </property>
                      <property name="jndiName">
                      <value>AccountService</value>
                      </property>
                      <property name="service">
                      <ref bean="accountService"/>
                      </property>
                      </bean>

                      __________________________________________________ __________

                      When i load the Application context i get the follwoing error
                      even though i have generated the iiop stubs using
                      rmic -iiop core.security.service.impl.AccountServiceImpl

                      java.rmi.StubNotFoundException: Stub class not found: $Proxy8_Stub; nested exception is:
                      java.lang.ClassNotFoundException: $Proxy8_Stub
                      at sun.rmi.server.Util.createStub(Util.java:274)
                      at sun.rmi.server.Util.createProxy(Util.java:122)
                      at sun.rmi.server.UnicastServerRef.exportObject(Unica stServerRef.java:169)
                      at java.rmi.server.UnicastRemoteObject.exportObject(U nicastRemoteObject.java:293)
                      at java.rmi.server.UnicastRemoteObject.exportObject(U nicastRemoteObject.java:220)
                      at com.sun.corba.se.impl.javax.rmi.PortableRemoteObje ct.exportObject(PortableRemoteObject.java:103)Appl ication Context File Not found at specified location...

                      at javax.rmi.PortableRemoteObject.exportObject(Portab leRemoteObject.java:87)
                      at org.springframework.remoting.rmi.JndiRmiServiceExp orter.afterPropertiesSet(JndiRmiServiceExporter.ja va:120)
                      at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1059)
                      at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:363)
                      at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:226)
                      at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:147)
                      at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:275)
                      at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:320)
                      at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:87)
                      at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:72)
                      at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:63)
                      at com.quark.qpp.QPPServer.main(QPPServer.java:26)
                      Caused by: java.lang.ClassNotFoundException: $Proxy8_Stub
                      at java.net.URLClassLoader$1.run(URLClassLoader.java: 200)
                      at java.security.AccessController.doPrivileged(Native Method)
                      at java.net.URLClassLoader.findClass(URLClassLoader.j ava:188)
                      at java.lang.ClassLoader.loadClass(ClassLoader.java:3 06)
                      at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:268)
                      at java.lang.ClassLoader.loadClass(ClassLoader.java:2 51)
                      at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:319)
                      at java.lang.Class.forName0(Native Method)
                      at java.lang.Class.forName(Class.java:242)
                      at sun.rmi.server.Util.createStub(Util.java:268)

                      Please help me on this issue

                      Thanks in Advance

                      Regards
                      -gerry

                      Comment


                      • #12
                        I have the same problem.
                        And extending UnicastRemoteObject can not solve this problem.

                        Have you got the solution?

                        Thanks.

                        Regards,
                        zheng

                        Comment

                        Working...
                        X