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

B

bond

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,
 
M

Mark Jeffcoat

bond said:
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.
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top