PDA

View Full Version : Spring RMI Server - plain RMI client


schuermann
Nov 2nd, 2005, 04:11 AM
Hi!

I'm having problems using a plain RMI client to access a remote server set up using Spring (using RmiServiceExporter). When trying to cast the object returned by java.rmi.Naming.lookup(...) to the actual "remote" interface I get a java.lang.ClassCastException. The remote object returned is of type: org.springframework.remoting.rmi.RmiInvocationWrap per_Stub. The service exported by RmiServiceExporter does not declare any RMI-specific interfaces of exceptions - it is a POJO.
Using a Spring-based client works just fine, but I cannot restrict access to Spring-based clients only.

Chapter 16.2.1 in the Spring Reference Documentation states that it is indeed possible to access a Spring RMI object using plain RMI.

Any ideas as to what I am doing wrong?

schuermann
Nov 18th, 2005, 03:57 AM
Not much feedback to get from this forum, but got an answer from Joergen Hoeller (thanks Kaare Nilsen!):
"To be able to access a Spring-exported RMI service from a tradtional RMI client, you need to use traditional RMI exposure. Spring's RmIServiceExporter will automatically switch to traditional exposure if you point it to a target service object that implements the java.rmi.Remote marker interface, assuming that it is a service implementation that follows the standard RMI convention. Usually, such a traditional RMI service object will in turn delegate to Spring-managed service beans in the backend, essentially being a thin remote facade."

- Rune -