Strange problem w/ RMI HTTP to CGI socket factory
sarel at botha.us
Thu Oct 11 12:57:48 PDT 2007
This problem seems strange to me and I don't know where to look to
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 net-dev