4 Replies Latest reply on May 16, 2008 2:24 AM by Narender Reddy

    JavaMail : java.lang.ClassCastException: javax.mail.Session

    Narender Reddy Newbie

      Hi

      My Code is mentioned below for JavaMail in Jboss AS-4.2.2

      Context envCtx =new InitialContext();
       Object obj = envCtx.lookup("java:/Mail");
       session =(javax.mail.Session)obj;


      This code for gettinh the JavaMail from Jboss As

      mail configuration is configured in mail-service.xml file

      whenever i am try to executed the above code i am getiing this below error

      16:22:34,814 INFO [STDOUT] envCtx........->javax.naming.InitialContext@1e9093a
      16:22:34,814 INFO [STDOUT] Object........->javax.mail.Session@5cd34e
      16:22:34,814 ERROR [STDERR] java.lang.ClassCastException: javax.mail.Session
      16:22:35,299 ERROR [STDERR] at com.gssamerica.expensereporting.ui.common.Mail.sendMail(Mail.java:62)
      16:22:35,299 ERROR [STDERR] at com.gssamerica.expensereporting.ui.applicationadministrator.ApplicationAdminAction.saveNewAdmin(ApplicationAdminAction.java:843)
      16:22:35,299 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      16:22:35,299 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      16:22:35,299 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

      If anyone knows the solution please help me ...


      Thanks&Regards,