Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javamail as JNDI resource in tomcat

We want to send mail from inside my tomcat web application.

I inherited some code from a predecessor that uses a context configuration file inside tomcat to define the data source that I use in my application through a JNDI lookup. This file currently looks like this:

<Context path="/chronicle" debug="5" reloadable="true" crossContext="true">

<Logger className="org.apache.catalina.logger.FileLogger" prefix="ej-Log." suffix=".txt" timestamp="true"/>
<Resource   name="jdbc/chronicle" 
                auth="Container"
            type="javax.sql.DataSource"
            username="sa"
            password="xxxxxxxx"
                driverClassName="net.sourceforge.jtds.jdbc.Driver" 
                url="jdbc:jtds:sqlserver://localhost/PsDb"
                maxActive="-1"
                maxIdle="0"
/>
</Context>

I have never been able to find documentation for this and never met the guy who did it so I don't really understand it, I simply know that it works.

This morning, it occurred to me that I could use the same tools to configure the mail server. Does anyone know how to do this inside the context configuration file?

like image 547
Thom Avatar asked Jan 27 '26 16:01

Thom


1 Answers

The Tomcat user guide tells you how to do it:

Tomcat 7 JNDI How-To

I didn't check to see if it changed from Tomcat 6 so here's that too:

Tomcat 6 JNDI How-To

like image 156
Paul Avatar answered Jan 29 '26 05:01

Paul



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!