Re: Mail Session ClassCastException

2005-06-29 Thread Carlos Bracho
Thanks Dirk, you were right, I had the jar files in common/lib and also in 
the web-inf/lib

Thanks again

On 6/29/05, Dirk Weigenand [EMAIL PROTECTED] wrote:
 
 Hi Carlos,
 
  --- Ursprüngliche Nachricht ---
  Von: Carlos Bracho [EMAIL PROTECTED]
  An: tomcat-user@jakarta.apache.org
  Betreff: Mail Session ClassCastException
  Datum: Tue, 28 Jun 2005 10:08:28 -0400
 
  Hello everybody.
 
  I am trying to get a mail session using the context's lookup method and 
 I
  get a ClassCastException.
 
  this is the resource declaration in my context.xml:
 
  Resource name=mail/sessionMail auth=Container
  type=javax.mail.Session
  mail.smtp.host=localhost/
 
  the code I am using to lookup the resource is:
 
  Context initialContext = new InitialContext();
  Object objeto = initialContext.lookup(java:comp/env/mail/sessionMail);
  String clase = objeto.getClass().getName();
  if(objeto instanceof javax.mail.Session)
  {
  this.session = (javax.mail.Session) objeto;
  }
 
  when I debug that code I see the clase variable has 
 javax.mail.Session
  as value but the if test does not pass
 
 
 I think your code is correct. What you are running into here is a case of
 loading classes via different class loaders. Check that your tomcat
 installation and your webapp do not both contain mail.jar. The bean 
 factory
 which provides your javax.mail.Session loads the class probably from the
 common/lib/mail.jar and your webapp gets this class from its
 WEB-INF/lib/mail.jar so they are both instances of javax.mail.Session but
 since loaded via different class loaders not really the same classes.
 
  Can anybody help men??
 
 Regards,
 Dirk
 
 --
 Weitersagen: GMX DSL-Flatrates mit Tempo-Garantie!
 Ab 4,99 Euro/Monat: http://www.gmx.net/de/go/dsl
 



-- 
--
Carlos J, Bracho M. 
--
e-mail: [EMAIL PROTECTED]
MSN: [EMAIL PROTECTED]
+58 416 409 21 75 
--


Mail Session ClassCastException

2005-06-28 Thread Carlos Bracho
Hello everybody.

I am trying to get a mail session using the context's lookup method and I 
get a ClassCastException.

this is the resource declaration in my context.xml:

Resource name=mail/sessionMail auth=Container type=javax.mail.Session 
mail.smtp.host=localhost/

the code I am using to lookup the resource is:

Context initialContext = new InitialContext();
Object objeto = initialContext.lookup(java:comp/env/mail/sessionMail);
String clase = objeto.getClass().getName();
if(objeto instanceof javax.mail.Session)
{
this.session = (javax.mail.Session) objeto;
}

when I debug that code I see the clase variable has javax.mail.Session 
as value but the if test does not pass

Can anybody help men??

thanks

-- 
--
Carlos J, Bracho M. 
--
e-mail: [EMAIL PROTECTED]
MSN: [EMAIL PROTECTED]
+58 416 409 21 75 
--