commons httpclient - PutMethod run OutOfMemoryError ??

Discussion in 'Java' started by Bastian, Dec 6, 2005.

  1. Bastian

    Bastian Guest

    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();
    }
     
    Bastian, Dec 6, 2005
    #1
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.