You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Sanjeev Saha <ss...@micropact.com> on 2005/11/11 21:26:07 UTC

email - Unable to get session while in a Thread

Hello:

 

I am trying to send a SimpleEmail asynchronously through a thread using
commons-email-1.0 final release. The steps being used are:

 

1)      email = new Email() <-- this is a custom class which extends
SimpleEmail

2)      set all email related values on email

3)      thread = new EmailThread(email) <-- EmailThread extends Thread

4)      thread.start() <-- the run() in EmailThread calls email.send()

 

However, on closely scrutinizing the process, the statement:

            this.session =

                Session.getInstance(properties, this.authenticator);

 

in org.apache.commons.email.Email never returns (e.g. a
System.out.println("test") just after the stmt. doesn't print anything)
and the thread stops without sending the email. If debug is set on the
email object to 'true', the following is printed on the console:

 

DEBUG: JavaMail version 1.3

DEBUG: java.io.FileNotFoundException:
C:\myself\programs\java\1.4.2_08\jre\lib\javamail.providers (The system
cannot find the file specified)

DEBUG: !anyLoaded

DEBUG: not loading resource: /META-INF/javamail.providers

 

Interestingly,  if email.send() is called outside of the Thread, every
thing works fine.

 

Any ideas or suggestions would be wonderful.

 

Thanks,

Sanjeev