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();
       javax.mail.Session s = (javax.mail.Session)ctx.lookup("java:comp/env/mail/DefaultMail");
      } catch (Exception e) {

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

      java.lang.ClassCastException: javax.mail.Session

      Please advise... Thanks!