title: fixing apache v9.0 Server Tomcat v9.0 Server at localhost failed to start error
body: <p>i have a simple java ee project which i need to send an email to a user, i found that it is possible with javamail and the gmail free smtp.</p>
  
  <p>my mail sender implementation:</p>
  
  <pre><code>package duck.reg.pack;
  
  import javax.servlet.annotation.WebServlet;
  import javax.servlet.http.HttpServlet;
  import java.util.Properties;
  
  import javax.mail.Message;
  import javax.mail.MessagingException;
  import javax.mail.PasswordAuthentication;
  import javax.mail.Session;
  import javax.mail.Transport;
  import javax.mail.internet.InternetAddress;
  import javax.mail.internet.MimeMessage;
  
  @WebServlet("/sendmailtls")
  public class SendMailTLS extends HttpServlet {
  public static void main(){
  
  final String username = "john.fob@gmail.com";
  final String password = "Password";
  
  Properties props = new Properties();
  props.put("mail.smtp.auth", "true");
  props.put("mail.smtp.starttls.enable", "true");
  props.put("mail.smtp.host", "smtp.gmail.com");
  props.put("mail.smtp.port", "587");
  
  Session session = Session.getInstance(props, new javax.mail.Authenticator() {
      protected PasswordAuthentication getPasswordAuthentication() {
          return new PasswordAuthentication(username, password);
      }
  });
  
  try {
  
      Message message = new MimeMessage(session);
      message.setFrom(new InternetAddress("joh.fob@gmail.com"));
      message.setRecipients(Message.RecipientType.TO,
          InternetAddress.parse("jon.fob@yahoo.com"));
      message.setSubject("Testing Subject");
      message.setText("Dear Mail Crawler,"
          + "\n\n No spam to my email, please!");
  
      Transport.send(message);
  
      System.out.println("Done");
  
  } catch (MessagingException e) {
      throw new RuntimeException(e);
  }
  }
  }
  </code></pre>
  
  <p>now the problem is that when ever i compile my program i get apache error saying:</p>
  
  <blockquote>
    <p>'Starting tomcat v9.0 Server at localhost' has encountered a problem.
    Server Tomcat v9.0 Server at localhost failed to start.</p>
  </blockquote>
  
  <p>and i found that if i remove </p>
  
  <pre><code>Session session = Session.getInstance(props, new javax.mail.Authenticator() {
  protected PasswordAuthentication getPasswordAuthentication() {
      return new PasswordAuthentication(username, password);
  }
  });
  </code></pre>
  
  <p>it compile just fine.</p>