JavaMail : java.lang.ClassCastException: javax.mail.Session
knarenderreddy May 16, 2008 12:17 AMHi
configuration is mentioned below for jboss4.2.2 AS
where is the problem , is their any additional configuration is required , i am going to get any thing wrong please help on this essue Urgent please.....
if any one knows the solution please help me Urgent......
I mentioned my Configuration Here
Configuration in mail-service.xml file
<?xml version="1.0" encoding="UTF-8"?> <!-- $Id: mail-service.xml 62349 2007-04-15 16:48:15Z dimitris@jboss.org $ --> <server> <!-- ==================================================================== --> <!-- Mail Connection Factory --> <!-- ==================================================================== --> <mbean code="org.jboss.mail.MailService" name="jboss:service=Mail"> <attribute name="JNDIName">java:/Mail</attribute> <attribute name="User">keshireddy.narender@abc.com</attribute> <attribute name="Password">Knreddy03</attribute> <attribute name="Configuration"> <!-- A test configuration --> <configuration> <!-- Change to your mail server prototocol --> <!-- <property name="mail.store.protocol" value="pop3"/> --> <property name="mail.transport.protocol" value="smtp"/> <!-- Change to the user who will receive mail --> <property name="mail.user" value="keshireddy.narender@abc.com"/> <!-- Change to the mail server --> <property name="mail.pop3.host" value="pop3.nosuchhost.nosuchdomain.com"/> <!-- Change to the SMTP gateway server --> <property name="mail.smtp.host" value="mail.abc.com"/> <!-- The mail server port --> <property name="mail.smtp.port" value="25"/> <!-- Change to the address mail will be from --> <property name="mail.from" value="keshireddy.narender@abc.com"/> <!-- Enable debugging output from the javamail classes --> <property name="mail.debug" value="true"/> <property name="mail.smtp.auth" value="true"/> </configuration> </attribute> <depends>jboss:service=Naming</depends> </mbean> </server>
Configuration in web.xml file
<resource-ref> <res-ref-name>mail/DefaultMail</res-ref-name> <res-type>javax.mail.Session</res-type> <jndi-name>java:/Mail</jndi-name> <res-auth>Container</res-auth> </resource-ref>
Configuration in jboss-web.xml file
<resource-ref> <res-ref-name>mail/DefaultMail</res-ref-name> <res-type>javax.mail.Session</res-type> <jndi-name>java:/Mail</jndi-name> <res-auth>Container</res-auth> </resource-ref>
and This is my code for getting the mail session
Context envCtx =new InitialContext(); javax.mail.Session session = (javax.mail.Session) envCtx.lookup("java:/Mail");
whenever i am trying to send the mail i am getting the bellow error
09:33:58,967 INFO [STDOUT] envCtx........->javax.naming.InitialContext@101044
09:33:59,358 ERROR [STDERR] java.lang.ClassCastException: javax.mail.Session
09:33:59,358 ERROR [STDERR] at com.gssamerica.expensereporting.ui.common.Mail.sendMail(Mail.java:59)
09:33:59,358 ERROR [STDERR] at com.gssamerica.expensereporting.ui.applicationadministrator.ApplicationAdminAction.saveNewAdmin(ApplicationAdminAction.java:843)
09:33:59,358 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
09:33:59,358 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
09:33:59,842 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
09:33:59,842 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
09:33:59,842 ERROR [STDERR] at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)
09:33:59,842 ERROR [STDERR] at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)
09:33:59,842 ERROR [STDERR] at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
09:34:00,342 ERROR [STDERR] at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
where is the problem , is their any additional configuration is required , i am going to get any thing wrong please help on this essue Urgent please.....
if any one knows the solution please help me
Thanks & Regards,