-
Jan 10th, 2008, 11:06 AM
#1
Exporting a service POJO using RMI twice
Have a service POJO that I need to export twice, once using plain sockets and again with SSL.
Running into all sorts of problems mainly due to the environment this is to be used in so wondered if I'd missed any easy way to do this.
First up, I'm finding that where the service is exported in traditional RMI style then it can only be exported once. Trying to export it a second time results in:
java.rmi.server.ExportException: object already exported
If I avoid making the service implement Remote then it appears I can export it more than once as an RmiInvocationHandler is used but this creates other problems.
If the server component is running on JVM 1.5 it seems a java.rmi.server.RemoteObjectInvovationHandler (since 1.5) is needed at the client. Some of my clients are running on JVM 1.4 so don't have this.
[This was because there wasn't a _Stub for the service class available]
If the server component is running on JVM 1.4 it seems an org.springframework.remoting.rmi.RmiInvocationWrap per_Stub is needed at the client. It isn't easy for me to arrange for this.
Are my understandings correct here? Currently I'm thinking I'm going to have to add spring-remoting to the client apps which will require a fair amount of classloader hell that I'd rather not get into. Is there any other way around this?
Cheers,
Last edited by derek; Jan 11th, 2008 at 06:02 AM.
-
Jan 11th, 2008, 05:40 AM
#2
Was able to solve the problem. Fortunately I was exporting a different interface to the Service each time. With only one of these extending Remote, the export of that was done in a traditional manner. This meant it could be accessed from clients on 1.4 or 1.5 so long as I added a _Stub for the service class there (which didn't present any difficulties with classloaders in the way adding the Spring jars would have). The other interface didn't extend Remote so the second export was done with an RmiInvocationWrapper. I didn't face the JVM version or classloader hell with the clients of that service so that was ok.
-
Jan 11th, 2008, 10:40 AM
#3
For future reference:
Ran into a further problem as each of the Registries/Services was to be exposed via a different IP address. This means I couldn't simply specify the IP address to bind the service to using -Djava.rmi.server.hostname
If registryHost property is specified, RmiServiceExporter doesn't attempt to create a registry as it expects it to be a remote registry.
Workaround was to pre start registries (without need to specify an IP address), then in Spring config, specify the registryHost with the IP address the service is intended to be bound to.
-
Jun 1st, 2009, 09:58 AM
#4
Hi Derek,
Can you please explain "This meant it could be accessed from clients on 1.4 or 1.5 so long as I added a _Stub for the service class there" in a bit more detail?
I am facing Invocation handler problem, whereby my RMI server is on a machine with JDK 1.5+ and my client machine is on JDK 1.4
Many thanks
Varun
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules