This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I am trying to test an example using RMI over SSL.
The example doesn't give me an error when I use LocateRegistry.createRegistry(<port> to start a registry in the application. When I comment out the LocateRegistry and use the command line rmiregistry <port> I get this error when it tries to do Naming.bind(name, server);.
I think it's because you're setting the SecureRMISocketFactory as the RMISocketFactory - it's probably assuming that *all* socket communication is going to be using SSL. If you start the registry outside the server, it's not going to be using this SocketFactory, so when your server tries to register with the registry, it uses an SSL socket, but gets a "regular" socket response from the registry.
It's possible to use the "regular" registry, but still use a custom socket factory between your client and server - the Using a Custom Socket Factory guide on Sun's site shows how.
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Joined: Jul 01, 2002
That worked and also understood the concept. I really appreciate your answer.
Joined: Jul 01, 2002
I start my server with the following code, which works perfect, it doesn't give an exception if I run the main method in this class.
If I try to run the client, i get the error.
one thing I have noted, the NotSerializableException does not occur with the Registry.rebind invocation is that you invoke rebind on a registry reference returned from LocateRegistry.createRegistry
It think the problem is that your SSLSocketFactory inside your RMISSLClientSocketFactory isn't serializable. You should mark that field as "transient" and restore the value inside a "readObject()" method.
For more information on how the transient keyword and readObject()/writeObject() works with Serializable objects - here's an article that covers it...