java.io.FileNotFoundException: velocity.log (Too many open files) when i use velocity to send email

Discussion in 'Java' started by bond, Jun 27, 2007.

  1. bond

    bond Guest

    Hi,
    I am using velocity templates to generate emails in a stand alone
    application.
    During the life cycle of the application, i generate 5 emails. But i
    am facing a problem now:

    If i run this stand alone application say more than 3 times
    continuosly, i get the below error and mails are not being sent after
    that.If i restart the server, start the application, then the mails
    will be sent without any problems for next 3 runs. Is it a bug with
    Velocity itself or bug in the way i implemented it?

    I googled it and found many people face same problem. But couldn't get
    any solution for it. So thought this is the right place to post it.

    PANIC : error configuring SimpleLog4JLogSystem :
    java.io.FileNotFoundException: velocity.log (Too many open files)

    log4j:WARN No appenders could be found for logger
    (org.apache.velocity.runtime.log.SimpleLog4JLogSys tem).

    log4j:WARN Please initialize the log4j system properly.

    Can any one please help me to overcome this problem?

    I am using the log4J for logging instead of AvalonLogSystem.

    Here is the steps what i do for sending emails:
    1. Initialize the velocity --- > Velocity.init(p); where 'p' is the
    properties file.
    this is done once per life cycle of the application.

    2.Create the new instance of velocitycontext for each mail --->

    VelocityContext context = new VelocityContext();

    put the data to context.

    So in my case i have 3 different mails whcih need to be sent. So i
    have created 3 instances of VelocityContext. Is it creating the
    problem?

    Please note that, if i run my application once in a day, it works
    fine.
    I feel it is some thing to do with the way Velocity does the file
    handling....


    Please help me to overcome this problem.

    Thanks in advance,
    bond, Jun 27, 2007
    #1
    1. Advertising

  2. bond <> writes:

    > If i run this stand alone application say more than 3 times
    > continuosly, i get the below error and mails are not being sent after
    > that.If i restart the server, start the application, then the mails
    > will be sent without any problems for next 3 runs. Is it a bug with
    > Velocity itself or bug in the way i implemented it?


    I use Velocity in a production setting, constructing a few
    hundred messages per day. I know which way I'm betting.

    >
    > I googled it and found many people face same problem. But couldn't get
    > any solution for it. So thought this is the right place to post it.
    >
    > PANIC : error configuring SimpleLog4JLogSystem :
    > java.io.FileNotFoundException: velocity.log (Too many open files)
    >
    > log4j:WARN No appenders could be found for logger
    > (org.apache.velocity.runtime.log.SimpleLog4JLogSys tem).
    >
    > log4j:WARN Please initialize the log4j system properly.


    Well, you can solve your log4j problem by putting a good
    log4j.properties in your classpath. I suspect that Velocity
    is trying to tell you more about what's going wrong, and you
    might get more information that way. But that's not what's
    causing you to run out of file handles.

    >
    > Can any one please help me to overcome this problem?
    >
    > I am using the log4J for logging instead of AvalonLogSystem.
    >
    > Here is the steps what i do for sending emails:
    > 1. Initialize the velocity --- > Velocity.init(p); where 'p' is the
    > properties file.
    > this is done once per life cycle of the application.
    >
    > 2.Create the new instance of velocitycontext for each mail --->
    >
    > VelocityContext context = new VelocityContext();
    >
    > put the data to context.
    >


    That should be fine. Something's missing: what do you
    merge the context with? Most people load their template
    from files; I'm guessing something's going wrong there.

    If you can, by chopping out everything extraneous, get
    this failure to appear in less than 100 lines of code or
    so, just post the whole thing, and I'll be happy to take
    a look.

    --
    Mark Jeffcoat
    Austin, TX
    Mark Jeffcoat, Jun 28, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Cathy  Hui
    Replies:
    6
    Views:
    9,059
    Wiseguy
    Mar 4, 2005
  2. HemantS
    Replies:
    0
    Views:
    787
    HemantS
    Jun 12, 2007
  3. bond
    Replies:
    3
    Views:
    22,418
  4. _pr0p
    Replies:
    2
    Views:
    4,799
    _pr0p
    May 14, 2008
  5. Dag Sunde
    Replies:
    4
    Views:
    353
Loading...

Share This Page