javax.naming.NamingException: Name not found java:/Mail

version:jboss 4.0.1 final

jbuilder10 , cause error code below:
public void test() {
    InitialContext ctx = null;
    javax.mail.Session session = null;
    try {
      Properties prop = new java.util.Properties();
      prop.put(InitialContext.INITIAL_CONTEXT_FACTORY,
               "org.jnp.interfaces.NamingContextFactory");
      prop.put(InitialContext.PROVIDER_URL, "jnp://localhost:1099");
      prop.put("java.naming.factory.url.pkgs", "org.jboss.naming.client");
      try {
        ctx = new InitialContext(prop);
      }
      catch (NamingException ex) {
        ex.printStackTrace();
      }

      Object obj = ctx.lookup("java:/Mail");
      System.out.println(obj.getClass());
      //javax.naming.Reference ref;
      //session =(Session) obj;
      session = (javax.mail.Session) PortableRemoteObject.narrow(obj,
          javax.mail.Session.class); //java:/Mail    java:/
    }
    catch (Exception ex) {
      ex.printStackTrace();
    }
    //Store store=session.getStore();
    //  Message msg=store.createMessage();
    MimeMessage mm = new MimeMessage(session);
    Address[] addrs = null;
    try {
      addrs = new javax.mail.internet.InternetAddress[] {
          new InternetAddress("[EMAIL PROTECTED]"),
          new InternetAddress("[EMAIL PROTECTED]")};

      mm.setFrom();
      mm.setRecipients(javax.mail.Message.RecipientType.TO, addrs);
      mm.setSubject("title");
      mm.setSentDate(new java.util.Date());
      mm.setContent("this is a test from jboss!", "text/plain");
//Store st = session.getStore();
//st.connect();
      Transport.send(mm);
    }
    catch (AddressException ex1) {
      ex1.printStackTrace();
    }
    catch (MessagingException ex2) {
      ex2.printStackTrace();
    }
  }


View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3874722#3874722

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3874722


-------------------------------------------------------
This SF.Net email is sponsored by: New Crystal Reports XI.
Version 11 adds new functionality designed to reduce time involved in
creating, integrating, and deploying reporting solutions. Free runtime info,
new features, or free trial, at: http://www.businessobjects.com/devxi/728
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to