Results 1 to 3 of 3
  1. #1
    TimmerCA is offline Member
    Join Date
    Jun 2012
    Posts
    11
    Rep Power
    0

    Default Tomcat + JavaMail + TLS + SMTP AUTH + Comcast

    I am developing a Java EE application behind a Comcast residential connection. Comcast requires TLS and SMTP AUTH to send outbound e-mail, so I'm trying to configure an SMTP connection that uses TLS and SMTP AUTH as a JNDI resource like this:

    Java Code:
    <Resource name="mail/smtp"
                auth="Container"
                type="javax.mail.Session"
                password="password"
                mail.debug="true"
                mail.user="user@comcast.net"
                mail.transport.protocol="smtp"
                mail.smtp.host="smtp.comcast.net"
                mail.smtp.auth="true"
                mail.smtp.port="587"
                mail.smtp.starttls.enable="true" />
    In my code, I try to initiate a session like this:

    Java Code:
    Context initialContext = new InitialContext();
    
    Session session = (Session) initialContext.lookup("java:comp/env/mail/smtp");
    When I do so, I get:

    Java Code:
    java.lang.NoClassDefFoundError: javax/mail/Authenticator
    What am I missing here? The entire JavaMail library is included in my application, and if I instantiate a Session by hard-coding the authentication parameters everything works just fine, so I'm pretty sure that the class is included correctly.

  2. #2
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    878
    Rep Power
    11

    Default Re: Tomcat + JavaMail + TLS + SMTP AUTH + Comcast

    Have you added the jars in tomcat lib directory.put some print statements.
    Ramya:cool:

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Tomcat + JavaMail + TLS + SMTP AUTH + Comcast

    Quote Originally Posted by TimmerCA View Post
    What am I missing here? The entire JavaMail library is included in my application,
    Indeed, but the Resource is configured and managed by the server, not your application. As such you need to do what RamyaSivakanth mentions: put the relevant javamail libraries in tomcat/lib so the classes are available to the server itself.

    given that it is a <Resource> I assume this is running on Tomcat; you may want to consider using TomEE instead which is Tomcat with JavaEE capabilities (including Javamail).
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Looking for the best JSF user auth in my case
    By mnd017 in forum JavaServer Faces (JSF)
    Replies: 1
    Last Post: 12-11-2012, 07:54 AM
  2. Bypas Auth In Java File Problem
    By Zyzex in forum Jobs Offered
    Replies: 1
    Last Post: 03-20-2012, 05:28 AM
  3. Bypas Auth In Java File Problem
    By Zyzex in forum New To Java
    Replies: 0
    Last Post: 03-20-2012, 04:57 AM
  4. Replies: 2
    Last Post: 08-24-2011, 04:32 PM
  5. javamail smtp ssl yahoomail,hotmail
    By Jhovarie in forum Threads and Synchronization
    Replies: 0
    Last Post: 02-24-2011, 01:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •