Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Spring RMI Remoting -Plain RMI Client

  1. #1
    Join Date
    Mar 2006
    Posts
    5

    Exclamation 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. #2
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    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

  3. #3
    Join Date
    Mar 2006
    Posts
    5

    Default

    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

  4. #4
    Join Date
    Aug 2004
    Posts
    2,715

    Default

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

    Regards,
    Andreas

  5. #5
    Join Date
    Mar 2006
    Posts
    5

    Default

    Thanks Andreas,

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

    Regards

  6. #6
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    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

  7. #7
    Join Date
    Mar 2006
    Posts
    5

    Default

    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

  8. #8
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    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?

  9. #9
    Join Date
    Mar 2006
    Posts
    5

    Default

    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

  10. #10
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    Quote Originally Posted by skonathala
    Do you think extending UnicastRemoteObject calss would solev the problem?
    I would think so.

    Regards,
    Andreas

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •