Hello all,

I hope i will not pollute the list, but i'm affraid of being faced with a bug :-(

I have to send a mail with tomcat.
I followed the instructions of the tomcat documentation, corresponding my version (5.5).

Using this code:

 public static String sendMail(String destinataire, String login){

        Session session = null;
        try {
            Context initCtx = new InitialContext();
            Context envCtx = (Context) initCtx.lookup("java:comp/env");
line 36     session = (Session) envCtx.lookup("mail/MonMail");
            //session = envCtx.lookup("mail/MonMail");
        } catch (NamingException ex) {
              System.out.println("erreur au lookup");
           return ex.getMessage();
        }

I have the following error that i really dislike :

java.lang.ClassCastException: javax.mail.Session cannot be cast to javax.mail.Session
        at utils.MailHelper.sendMail(MailHelper.java:36)

I use the netbeans 5.5 bundled tomcat server (v 5.5.17) on the 1.6 java version (but source level set to 1.5).

Do you think it's me ? Or a bug of the IDE ? or a bug of tomcat ?

I previously used this code with the same config in a successful way with another tomcat 5.5 server.

I'm getting crazy with this awful and strange cast error :-(
If only someone could help...

I join the web.xml tag:

<resource-ref>
        <description>
            Resource reference to a factory for javax.mail.Session
            instances that may be used for sending electronic mail
            messages, preconfigured to connect to the appropriate
            SMTP server.
        </description>
        <res-ref-name>mail/MonMail</res-ref-name>
        <res-type>javax.mail.Session</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>

and my server.xml

 <Resource
      name="mail/MonMail"
      type="javax.mail.Session"
      mail.smtp.host="smtp.free.fr"/>

and my context.xml

 <Resource name="mail/MonMail" auth="Container"
            type="javax.mail.Session"
            mail.smtp.host="smtp.free.fr"/>

Hope to hear soon from the list about this problem :-(
Best regards.

----------------------------------------------------
Ce message a ete envoye par le serveur IMP de l'EMA.



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to