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)
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.
Created attachment 13599 [details] adds a section 4 to javamail config mentioning the javamail libs and locations
I've applied your patch for Tomcat 5.5.5, will do 5.0.31 shortly. Thanks for submitting it ;)
Done for 5.0.31 as well.