2 Replies Latest reply on Aug 11, 2005 8:59 PM by Alexander Wallace

    JavaMail session lookup gives java.lang.ClassCastException:

    Alexander Wallace Newbie

      Hi, i'm trying to get a javax.mail.Session fron JNDI, and getting a ClassCastException, even tho if i do System.out.print() of the context lookup, i see a javax.mail.Session object instance...

      Here is the code:


      InitialContext ctx = new InitialContext();
      out.print(ctx.lookup("java:comp/env/mail/DefaultMail"));
      try{
       javax.mail.Session s = (javax.mail.Session)ctx.lookup("java:comp/env/mail/DefaultMail");
      } catch (Exception e) {
       out.println(e);
      }
      


      this is in a jsp, the result on the browser is:

      javax.mail.Session@96d2c2
      java.lang.ClassCastException: javax.mail.Session

      Please advise... Thanks!