title: ERROR Could not instantiate class
body: <p>I work with log4j.properties through WSO2 products. I needed implement a appender to work with SMTPAppender and send emails notifications using gmail smtp server. So, when I config log4j and start ESB WSO2 Server, the manage console print: <code>log4j:ERROR Could not instantiate class [com.notification.GmailSMTPAppender]</code>.</p>
  
  <p>My implementation was:</p>
  
  <pre><code>package com.notification;
  
  public class GmailSMTPAppender extends SMTPAppender {
  
      protected Session session;
  
      public GmailSMTPAppender() {
              super();
      }
  
      /**
       * Create mail session.
       *
       * @return mail session, may not be null.
       */
      protected Session createSession() {
              Properties props = new Properties();
              props.put("mail.smtps.host", getSMTPHost());
              props.put("mail.smtps.auth", "true");
  
              Authenticator auth = null;
              if (getSMTPPassword() != null &amp;&amp; getSMTPUsername() != null) {
                      auth = new Authenticator() {
                              protected PasswordAuthentication getPasswordAuthentication() {
                                      return new PasswordAuthentication(getSMTPUsername(),
                                                      getSMTPPassword());
                              }
                      };
              }
              session = Session.getInstance(props, auth);
              if (getSMTPProtocol() != null) {
                      session.setProtocolForAddress("rfc822", getSMTPProtocol());
              }
              if (getSMTPDebug()) {
                      session.setDebug(getSMTPDebug());
              }
              return session;
      }
  
      /**
       * Send the contents of the cyclic buffer as an e-mail message.
       */
      protected void sendBuffer() {
              try {
                      MimeBodyPart part = new MimeBodyPart();
  
                      StringBuffer sbuf = new StringBuffer();
                      String t = layout.getHeader();
                      if (t != null)
                              sbuf.append(t);
                      int len = cb.length();
                      for (int i = 0; i &lt; len; i++) {
                              LoggingEvent event = cb.get();
                              sbuf.append(layout.format(event));
                              if (layout.ignoresThrowable()) {
                                      String[] s = event.getThrowableStrRep();
                                      if (s != null) {
                                              for (int j = 0; j &lt; s.length; j++) {
                                                      sbuf.append(s[j]);
                                                      sbuf.append(Layout.LINE_SEP);
                                              }
                                      }
                              }
                      }
                      t = layout.getFooter();
                      if (t != null)
                              sbuf.append(t);
                      part.setContent(sbuf.toString(), layout.getContentType());
  
                      Multipart mp = new MimeMultipart();
                      mp.addBodyPart(part);
                      msg.setContent(mp);
  
                      msg.setSentDate(new Date());
                      send(msg);
              } catch (Exception e) {
                      LogLog.error("Error occured while sending e-mail notification.", e);
              }
      }
  
      /**
       * Pulled email send stuff i.e. Transport.send()/Transport.sendMessage(). So
       * that on required this logic can be enhanced.
       *
       * @param msg
       *            Email Message
       * @throws MessagingException
       */
      protected void send(Message msg) throws MessagingException {
              SMTPTransport t = (SMTPTransport) session.getTransport("smtps");
              try {
                      t.connect(getSMTPHost(), getSMTPUsername(), getSMTPPassword());
                      t.sendMessage(msg, msg.getAllRecipients());
              } finally {
                      System.out.println("Response: " + t.getLastServerResponse());
                      t.close();
              }
      }
  
  }
  </code></pre>
  
  <p>How I can instantiate of this appender on my log4j.properties configuration ??</p>