Hi All,
I'm using the following code to send Java objects over http to the server. In
most cases it works fine, but sometimes it throws
"java.net.SocketException: Connection reset" at the line highlighted in red
below and user simply gets an error message. After closing the message dialog
and retrying the same function, it goes through successfully. It don't know
what the pattern is for reproducing the error and this makes it hard to trace
and debug.
Does anybody have any ideas what the root cause could be?
BTW, I'm using httpclient version 3.0.
RemoteMethodCall remoteMethodCall = new RemoteMethodCall(jndiName,
method.getName(), args, method.getParameterTypes());
ByteArrayOutputStream byteArrayOutputStream = new
ByteArrayOutputStream();
new
ObjectOutputStream(byteArrayOutputStream).writeObject(remoteMethodCall);
byte[] remoteMethodCallAsByte = byteArrayOutputStream.toByteArray();
PostMethod postMethod = new PostMethod(logonContext.getUrl());
postMethod.setRequestEntity(new
ByteArrayRequestEntity(remoteMethodCallAsByte));
postMethod.setContentChunked(true);
httpClient.executeMethod(postMethod);
debugHttpMethod(postMethod);
try {
if (HttpStatus.SC_OK == postMethod.getStatusCode()) {
ObjectInputStream in = new
ObjectInputStream(postMethod.getResponseBodyAsStream());
RemoteMethodCallResults results =
(RemoteMethodCallResults)in.readObject();
Throwable resultException = results.getException();
if ( resultException == null) {
return results.getRVal();
}
throw resultException;
}
else if (requiresAuthetication(postMethod)) {
LogonContext lctx =
(LogonContext)RootApplicationContext.getContext().getBean("logon-context");
ValidationResults vr = authenticate(lctx.getUserName(),
lctx.getPassword());
if (vr.isValid())
return invoke(proxy, method, args);
throw new FrameworkException(remoteMethodCall + " failed: "
+ vr.getMessage());
}
else {
throw new FrameworkException(remoteMethodCall + " failed: "
+ postMethod.getResponseBodyAsString());
}
}finally {
postMethod.releaseConnection();
}
Thanks,
Mohammad
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com