I have tomcat6 running on ubuntu, with java 1.6.0_20.
One of the webapps causes an error, which has as root cause:
java.lang.ClassNotFoundException: javax.mail.Authenticator
the mail.jar and activation.jar (found these as culprit in my online research) are in the /var/lib/tomcat6/common/lib directory and in the lib directory of the webapp. The javax.mail.Authenticator.class is in mail.jar.
What else can I try to get it to work? are there logs anywhere that can help me find the real error?
update:
- removed the duplicate .jar files to avoid possible conflicts. tried
- running tomcat (on another machine, tomcat7 on windows) with verbose
class loading:
[Loaded javax.mail.Address from file:/C:/.../build/web/WEB-INF/lib/mail.jar] [Loaded javax.mail.internet.InternetAddress from file:/C:/.../build/web/WEB-INF/lib/mail.jar] [Loaded javax.mail.Part from file:/C:/.../build/web/WEB-INF/lib/mail.jar] [Loaded javax.mail.BodyPart from file:/C:/.../build/web/WEB-INF/lib/mail.jar] [Loaded javax.mail.internet.MimePart from file:/C:/.../build/web/WEB-INF/lib/mail.jar] [Loaded javax.mail.internet.MimeBodyPart from file:/C:/.../build/web/WEB-INF/lib/mail.jar] [Loaded javax.mail.Multipart from file:/C:/.../build/web/WEB-INF/lib/mail.jar] [Loaded javax.mail.internet.MimeMultipart from file:/C:/.../build/web/WEB-INF/lib/mail.jar] [Loaded javax.activation.DataSource from C:\Program Files\Java\jdk1.6.0_26\jre\lib\rt.jar] [Loaded javax.mail.Message from file:/C:/.../build/web/WEB-INF/lib/mail.jar] [Loaded javax.mail.internet.MimeMessage from file:/C:/.../build/web/WEB-INF/lib/mail.jar] [Loaded org.apache.naming.factory.MailSessionFactory from file:/C:/Program%20Files/Apache%20Software%20Foundation/Apache%20Tomcat%207.0.11/lib/catalina.jar] [Loaded org.apache.naming.factory.MailSessionFactory$1 from file:/C:/Program%20Files/Apache%20Software%20Foundation/Apache%20Tomcat%207.0.11/lib/catalina.jar] 28.07.2011 09:24:36 com.sun.faces.lifecycle.LifecycleImpl phase WARNUNG: executePhase(RENDER_RESPONSE 6,com.sun.faces.context.FacesContextImpl@698b41da) threw exception javax.faces.FacesException: [snip...] [...] Caused by: java.lang.ClassNotFoundException: javax.mail.Authenticator [...]
So that does not tell me anything new.
Best Answer
Do you use a mail session provided by Tomcat or do you create the mail session within your Application?
Look here for how to use a mail session provided by Tomcat:
http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html#JavaMail_Sessions
That is the way you want to use an SMTP connection in Tomcat.
If you are using the mail session provided by Tomcat it needs the mail and activation jar in the classpath of the Tomcat. Normally this is achieved by putting these jar files into the tomcat/lib directory (if you download the package from tomcat.apache.org)
I guess the problem you have is caused by the special Tomcat Ubuntu directory configuration - I do not know which directory is equal to the tomcat/lib directory there. I usually install the original distribution from tomcat.apache.org by simply extracting it into the desired directory on my Ubuntu machines.