Results 1 to 6 of 6

Thread: Properties of a J2EE application

  1. #1
    Join Date
    Dec 2009
    Posts
    213

    Properties of a J2EE application

    Hello,
    I need help solving a problem loading the properties of a J2EE application. I have a class that extends Configuration Properties and load the properties files from their url with this statement:
    Code:
    this.load(url.openStream());
    The change of properties is taken hot so I periodically scans the config files, and after a while I get this error:
    Code:
    java.io.FileNotFoundException: "Filename" (Too many open files)
    Obviously there is saturation of the file handle. Is it necessary to do something special to properly close files after reading them?

  2. #2
    Join Date
    Nov 2009
    Posts
    518

    Re: Properties of a J2EE application

    Hello,
    Just follow the following lines of code and it is done.
    Code:
    inputStream input = null;
    try {
       input = url.openStream();
       this.load(input);
    } finputally {
       if (input! = null) {
         input.close();
       }
    }
    (Not to mention the management of IOException, which depends on the method signature).

  3. #3
    Join Date
    Nov 2009
    Posts
    343

    Re: Properties of a J2EE application

    Hello,
    There are very long, really long time before the C + + there, I remember having to recompile the Linux kernel to increase the number of file descriptor. It is a problem with your OS or application (server I imagine that too many files or sockets open, or you left unsealed streams into objects that are still in use). You have probably hundreds of file descriptor. You should try to get how many are allocated. And you program should have more details.

  4. #4
    Join Date
    Nov 2009
    Posts
    335

    Re: Properties of a J2EE application

    Hello,
    If you're looking at the Linux command "ulimit-a" this gives you a lot of information about your configuration.
    Code:
    $ Ulimit-a
    core file size          (blocks,-c) 0
    data seg size           (kb,-d) unlimited
    scheduling priority             (-e) 0
    file size               (blocks,-f) unlimited
    pending signals                 (-i) 49842
    max locked memory       (kb,-l) 32
    Max memory size         (kb,-m) unlimited
    open files                      (-n) 1024
    pipe size            (512 bytes,-p) 8
    POSIX message queues     (bytes,-q) 819212
    real-time priority              (-r) 0
    stack size              (kb,-s) 10440
    cpu time               (seconds,-t) unlimited
    max user processes              (-u) 42552
    virtual memory          (kb,-v) unlimited
    File Lock                      (-x) unlimited
    Check this configuration this may help you.

  5. #5
    Join Date
    Nov 2009
    Posts
    583

    Re: Properties of a J2EE application

    Hi,
    Unless you have very large need that forces you to open simultaneously in a large number of files, you should not change the system limit. As shown yann2Your problem is that you do not shut your flow, and therefore you increase gradually the number of file / open resources. In closing the problem neatly disappear You do not need to handle null, and you can use the following syntax:
    Code:
    InputStream input = url.openStream(); / / If nothinputg is done IOException
    try {
       this.load(input);
    } finally {
       input.close();
    }

  6. #6
    Join Date
    Dec 2009
    Posts
    213

    Re: Properties of a J2EE application

    Hello,
    Indeed, the problem is solved with the finally clause that closes the flow. Thanks for your replies guys.
    Code:
    finally {
       input.close();
    }
    And also if this can be done in other way without using the finally block then I am interested. Thanks in advance.

Similar Threads

  1. How can I create JavaFX page in j2ee web application
    By Marjorie in forum Software Development
    Replies: 5
    Last Post: 25-07-2010, 03:26 AM
  2. The J2EE Application Has Not Been Deployed
    By Damien25 in forum Software Development
    Replies: 4
    Last Post: 05-02-2010, 01:34 AM
  3. Replies: 1
    Last Post: 16-12-2009, 01:11 PM
  4. What is EJB role in J2EE?
    By VinFanatic in forum Software Development
    Replies: 3
    Last Post: 12-09-2009, 09:07 AM
  5. How to use jta transactionmanager J2EE
    By RasMus in forum Software Development
    Replies: 3
    Last Post: 10-08-2009, 11:33 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,719,344,138.36917 seconds with 17 queries