Bug 32454 - A ClassCastException can be caused for JNDI mail session lookup
Summary: A ClassCastException can be caused for JNDI mail session lookup
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 5.5.4
Hardware: PC Windows 2000
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-30 17:58 UTC by Allistair Crossley
Modified: 2004-11-30 09:26 UTC (History)
0 users



Attachments
adds a section 4 to javamail config mentioning the javamail libs and locations (1.34 KB, patch)
2004-11-30 18:20 UTC, Allistair Crossley
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Allistair Crossley 2004-11-30 17:58:38 UTC
the JavaMail JNDI configuration for Tomcat requires activation.jar and 
mail.jar. 

a java.lang.ClassCastException: javax.mail.Session can be caused by placing 
mail.jar in common/lib *and* WEB-INF/lib and then attempting to obtain a 
Session from mail/Session JNDI context as per 5.5.4 docs. 

placing activation.jar in both locations does not cause the issue, it is 
confined to 2 copies of mail.jar. activation.jar and mail.jar should be located 
in common/lib for Tomcat to configure the JNDI factory. The question is whether 
the error _should_ occur or whether this is a user error for placing mail.jar 
in a webapp lib.

java.lang.ClassCastException: javax.mail.Session
	at com.qas.newmedia.common.email.MrPostMan.sendMessage
(MrPostMan.java:103)
	at com.qas.newmedia.common.email.MrPostMan.sendMessage
(MrPostMan.java:147)
	at com.qas.newmedia.intranet.pof.actions.create.CreateStep1Action.doWork
(CreateStep1Action.java:38)
	at com.qas.newmedia.intranet.iq.actions.SecuredBaseAction.execute
(SecuredBaseAction.java:151)
	at org.apache.struts.action.RequestProcessor.processActionPerform
(RequestProcessor.java:421)
	at org.apache.struts.action.RequestProcessor.process
(RequestProcessor.java:226)
	at org.apache.struts.action.ActionServlet.process
(ActionServlet.java:1158)
	at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:237)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:157)
	at com.qas.newmedia.common.filters.SetCharacterEncodingFilter.doFilter
(SetCharacterEncodingFilter.java:146)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:186)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:157)
	at org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:214)
	at org.apache.catalina.core.StandardContextValve.invoke
(StandardContextValve.java:178)
	at org.apache.catalina.core.StandardHostValve.invoke
(StandardHostValve.java:126)
	at org.apache.catalina.valves.ErrorReportValve.invoke
(ErrorReportValve.java:105)
	at org.apache.catalina.valves.FastCommonAccessLogValve.invoke
(FastCommonAccessLogValve.java:481)
	at org.apache.catalina.core.StandardEngineValve.invoke
(StandardEngineValve.java:107)
	at org.apache.catalina.connector.CoyoteAdapter.service
(CoyoteAdapter.java:148)
	at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:300)
	at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:383)
	at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:743)
	at org.apache.jk.common.ChannelSocket.processConnection
(ChannelSocket.java:675)
	at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:866)
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run
(ThreadPool.java:684)
	at java.lang.Thread.run(Thread.java:595)
Comment 1 Yoav Shapira 2004-11-30 18:01:44 UTC
It's a user error, because it's the user that's placing (and controlling the 
location of) mail.jar and actiation.jar.  If you want to use them, use one 
version in one place.  Jar duplication across repositories like this is user 
error.  The docs on MailSession JNDI, however, should be amended to include 
this information.
Comment 2 Allistair Crossley 2004-11-30 18:20:37 UTC
Created attachment 13599 [details]
adds a section 4 to javamail config mentioning the javamail libs and locations
Comment 3 Yoav Shapira 2004-11-30 18:24:18 UTC
I've applied your patch for Tomcat 5.5.5, will do 5.0.31 shortly.  Thanks for 
submitting it ;)
Comment 4 Yoav Shapira 2004-11-30 18:26:43 UTC
Done for 5.0.31 as well.