commons httpclient - PutMethod run OutOfMemoryError ??

B

Bastian

hello,

when running the follwoing code, i get a error message from
SimpleHttpConnectionManager.releaseConnection:

WARNING: SimpleHttpConnectionManager being used incorrectly. Be sure
that HttpMethod.releaseConnection() ist always called and that only one
thread and/or method is this connection manager at a time.

And it throws java.lang.OutOfMemoryError

This happend only if try to upload bigger files (prob > 50MB) smaller
textfiles are no proplem with this code.


What can i do to solve that problem and what is the problem in detail?


thx
bastian


Code:

PutMethod method2 = null;
try {
method2 = new PutMethod(url+"/"+remote);
method2.setRequestEntity(
new InputStreamRequestEntity(

new FileInputStream( local ) ) );
} catch (FileNotFoundException e) {
log.warning("File doesnt exist: " + local);
e.printStackTrace();
return false;
}
long start = 0, time = 0, bytes = local.length();
try {
// Execute the method.
start = System.currentTimeMillis();
int statusCode =
httpclient.executeMethod(method2);
time = System.currentTimeMillis() - start;
if (statusCode != HttpStatus.SC_CREATED
&& statusCode !=
HttpStatus.SC_OK) {
log.warning("PutMethod failed: " +
method2.getStatusLine() + " Statuscode="+statusCode);
} else
ret = true;
} catch (HttpException e) {
log.severe("Fatal protocol violation: " +
e.getMessage());
e.printStackTrace();
} catch (IOException e) {
log.severe("Fatal transport error: " +
e.getMessage());
e.printStackTrace();
} finally {
// Release the connection.
method2.releaseConnection();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top