title: Cannot inject javax.mail.Session, jboss 7.1.1
body: <p>Jboss can't inject smtp server configuration into Session field.</p>
  
  <p>I've edited standalone.xml file:</p>
  
  <pre><code>&lt;mail-session jndi-name="java:jboss/mail/MyMail"&gt;
          &lt;smtp-server outbound-socket-binding-ref="mail-smtp-my-mail"&gt;
                 &lt;login name="login" password="passwd"/&gt;
          &lt;/smtp-server&gt;
  &lt;/mail-session&gt;
  ...
  &lt;socket-binding-group ...&gt;
      &lt;outbound-socket-binding name="mail-smtp-my-mail"&gt;
          &lt;remote-destination host="my-stmp-server" port="2587"/&gt;
      &lt;/outbound-socket-binding&gt;
  </code></pre>
  
  <p>My class which has Session field:</p>
  
  <pre><code>@Stateless
  public class MailHelper {
  
      @Resource(mappedName = "java:jboss/mail/MyMail")
      private Session mailSession;
  
      public String send() {
          MimeMessage m = new MimeMessage(mailSession);
          try {
              m.setRecipients(Message.RecipientType.TO, "g@gmail.com");
              Transport.send(m);
          } catch (MessagingException e) {
              e.printStackTrace();
          }
          return "...";
      }
  }
  </code></pre>
  
  <p>Mail helper is used in jsp page:</p>
  
  <pre><code>&lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
  &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
      "http://www.w3.org/TR/html4/loose.dtd"&gt;
  
  &lt;html&gt;
      &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
      &lt;title&gt;JSP Page&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h1&gt;Hello World!&lt;/h1&gt;
      &lt;jsp:useBean id="mailHelper" class="com.MailHelper" scope="session"/&gt;
      &lt;%= mailHelper.send()%&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>Every time I have null in mailSession field. What is wrong?</p>