2 Replies Latest reply on Oct 5, 2006 10:49 AM by James Rhodes

    newbie please help: using the right name?

    James Rhodes Newbie

      This is a really dumb question, but here goes: I'm trying to use javamail and I have the following config:
      Here is the server output when jboss starts up:

      [org.jboss.mail.MailService] Mail Service bound to java:/AppMail
      2006-10-04 12:46:46,065 DEBUG [org.jboss.mail.MailService] Started jboss:service=Mail


      <!-- Change to your mail server prototocol -->

      <!-- Change to the user who will receive mail -->

      <!-- Change to the mail server -->

      <!-- Change to the mail server -->

      Now if you notice I've called the jndi name java:/AppMail. How do I refer to this in the code? I always get NameNotFoundException. Here is my code:

      Context ctx = null;
      Session mailSession = null;
      try {
      ctx = (Context) new InitialContext().lookup("java:comp/env");

      Object objref = ctx.lookup("java:/AppMail");
      mailSession = (Session) PortableRemoteObject.narrow(objref, Session.class);
      } catch (NamingException e) {
      // TODO Auto-generated catch block
      e.printStackTrace( }

      Am I refering to jndi name in the proper way?