dcsimg
<big><big><code><strong>ClassCastException</strong> </code></big> caused by <big>!_NEWLINE_!<code>(Session) envCtx.lookup(Mailer.url);!_NEWLINE_!</code></big></big>
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Garrett_Smith
Posted On:   Friday, October 25, 2002 11:49 AM

Hey, I posted this on JNDI forum, but it may be a JavaMail question or even a general Java question. I'm perplexed by this. How can this code: Session session; try{ session = (Session) envCtx.lookup(Mailer.url); } catch(ClassCastException cce){ throw new ClassCastException("envCtx.lookup(Mailer.url).class = " +envCtx.lookup(Mailer.url).getClass().getName()); } Produce this error: java.lang.ClassCastException: envCtx.lookup(Mailer.url).class = javax.mail.Session at com.dhtmlkitchen.reg.mail.Mailer.sendMail(Mailer.java:110) at com.dhtmlkitchen.reg.mail.Mailer.sendReminder(Mailer.java:72)    More>>

Hey, I posted this on JNDI forum, but it may be a JavaMail question or even a general Java question. I'm perplexed by this.



How can this code:


			
Session session;
try{
session = (Session) envCtx.lookup(Mailer.url);
}
catch(ClassCastException cce){
throw new ClassCastException("envCtx.lookup(Mailer.url).class = "
+envCtx.lookup(Mailer.url).getClass().getName());
}


Produce this error:


			
java.lang.ClassCastException: envCtx.lookup(Mailer.url).class = javax.mail.Session
at com.dhtmlkitchen.reg.mail.Mailer.sendMail(Mailer.java:110)
at com.dhtmlkitchen.reg.mail.Mailer.sendReminder(Mailer.java:72)
at com.dhtmlkitchen.reg.ChangeAccount.doPost(ChangeAccount.java:68)

?


It happens every time. How and why?

   <<Less

Re: <big><big><code><strong>ClassCastException</strong> </code></big> caused by <big>!_NEWLINE_!<code>(Session) envCtx.lookup(Mailer.url);!_NEWLINE_!</code></big></big>

Posted By:   Christopher_Koenigsberg  
Posted On:   Friday, October 25, 2002 12:52 PM

What is the original content of the exception message text, before you re-throw your own version?

Re: <big><big><code><strong>ClassCastException</strong> </code></big> caused by <big>!_NEWLINE_!<code>(Session) envCtx.lookup(Mailer.url);!_NEWLINE_!</code></big></big>

Posted By:   Christopher_Koenigsberg  
Posted On:   Friday, October 25, 2002 12:00 PM

Did you try specifying "javax.mail.Session" for the type and the cast, instead of just the possibly ambiguous short name "Session", to see if that is the problem?

About | Sitemap | Contact