Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Apache Tomcat »

JNDI bound mail.Session and Spring's JavaMailSender

Mikolaj Rydzewski

2006-11-30

Replies:

Hi,

I thought it'd be a simple task: to send emails from Spring 2.0 webapp
using JNDI bound mail Session, everything on Tomcat 5.5.20. I've copied
mail.jar and activation.jar to common/lib.

I've got global resource in server.xml:

<Resource name="mail/Session"
    auth="Container"
    type="javax.mail.Session"
    mail.smtp.host="localhost"/>

I've got resource link in META-INF/context.xml:

  <ResourceLink name="mail/Session"
       global="mail/Session"
       type="javax.mail.Session"
       />

The same link in web.xml:

  <resource-ref>
    <res-ref-name>mail/Session</res-ref-name>
    <res-type>javax.mail.Session</res-type>
    <res-auth>Container</res-auth>
  </resource-ref>

And the Spring beans:

  <bean id="mailSession"
class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName">
       <value>java:comp/env/mail/Session</value>
    </property>
  </bean>

So everything should 'just work'. Unfortunately not:

org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'mailSession' defined in ServletContext resource
[/WEB-INF/applicationContext.xml]: Invocation of init method failed;
nested exception is javax.naming.NamingException: Could not create
resource factory instance [Root exception is
java.lang.ClassNotFoundException:
org.apache.naming.factory.MailSessionFactory]

Can somebody confirm that similiar setup works for him? Or where is the
mistake?

Regards

--
Mikolaj Rydzewski    <miki@(protected)/
            PGP KeyID: 8b12ab02
There are three kinds of people: men, women and unix.


Attachment: smime.p7s
©2008 junlu.com - Jax Systems, LLC, U.S.A.