[Fwd: Strange problem w/ RMI HTTP to CGI socket factory]

Christopher Hegarty - Sun Microsystems Ireland Christopher.Hegarty at Sun.COM
Fri Oct 12 12:04:14 UTC 2007

Forwarding this mail to the core libs mailing list as they are most 
probably in a better position to answer it as they own the sun.rmi package.


-------- Original Message --------
Subject: Strange problem w/ RMI HTTP to CGI socket factory
Date: Thu, 11 Oct 2007 15:57:48 -0400
From: Sarel Botha <sarel at botha.us>
To: net-dev at openjdk.java.net

Hi All,

This problem seems strange to me and I don't know where to look to
resolve it.

The RMIHttpToCGISocketFactory class is working well for me. I call
RMISocketFactory.setSocketFactory(new RMIHttpToCGISocketFactory ()),
then Naming.lookup() and all is well. However, I need to customize this
class a little, so I got a copy of the source code for the package
sun.rmi.transport.proxy, then renamed the package for these classes to
sun.rmi.transport.proxy2 (also tried openjdk.sun.rmi.transport.proxy).

If I try to use the same class in this package I get this error when it
tries to establish the RMI connection:
java.rmi.ConnectIOException: error during JRMP connection establishment;
nested exception is:
        java.io.IOException: attempt to write on HttpSendSocket after
request has been sent

What's happening is that the underlying RMI code is calling
HttpSendOutputStream.write() and passing only 7 bytes. This is
immediately sent to the server which responds with only about 18 bytes.
Then, it tries to call write() again, which should never happen, so it
throws the exception you see above.

When it works (using the socket factory that ships with JRE6) it first
sends 58 bytes and the server responds with 217 bytes. You can also see
the name of the RMI service in the request and the server response
contains the name of the stub and the IP where the service is running.

It seems like the underlying implementation is treating this socket
factory totally differently from the one it ships with.

Must the code be compiled with different switches maybe? Must the socket
factory be registered somewhere? Any pointers would be appreciated.


More information about the core-libs-dev mailing list