I'm having some difficulty setting up a shared email resource under
Tomcat and I can't seem to find the answer anywhere online. Everything
seems to be working under Tomcat, but for some reason my application
can't find the JNDI name..
In server.xml I have:
----------------Snip--------------------------
<GlobalNamingResources>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users
-->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
<Resource name="mail/Session"
type="javax.mail.Session"
auth="Container"
mail.smtp.host="myserver.com"
mail.smtp.auth="true"
username="myuser"
password="mypassword"
mail.user="myuser"
mail.password="mypassword"
mail.port="25"
mail.transport.protocol="smtp"
mail.debug="true"/>
</GlobalNamingResources>
--------------------------Snip--------------------------
In /etc/tomcat6/web.xml, I have:
-------------------------Snip---------------------------
<ResourceLink>
<name>mail/Session</name>
<global>mail/Session</global>
<type>javax.mail.Session</type>
</ResourceLink>
-------------------------Snip---------------------------
All I want is for any application to be able to use the JNDI mechanism to
lookup the mail session and use it. The error I'm getting when an
application actually tries to use the mail session is as follows:
-------------------------Snip--------------------------
Oct 15, 2009 9:58:21 AM org.apache.catalina.core.StandardContext
listenerStart
SEVERE: Exception sending context initialized event to listener instance
of class org.codehaus.groovy.grails.web.context.GrailsContextLoade
rListener
org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'mailSession': Invocation of init method failed; nes
ted exception is javax.naming.NameNotFoundException: Name mail is not
bound in this Context
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.catalina.core.StandardContext.listenerStart
(StandardContext.java:3843)
at org.apache.catalina.core.StandardContext.start
(StandardContext.java:4338)
at org.apache.catalina.core.ContainerBase.addChildInternal
(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild
(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild
(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployWAR
(HostConfig.java:830)
at org.apache.catalina.startup.HostConfig.deployWARs
(HostConfig.java:719)
at org.apache.catalina.startup.HostConfig.deployApps
(HostConfig.java:490)
at org.apache.catalina.startup.HostConfig.start
(HostConfig.java:1149)
at org.apache.catalina.startup.HostConfig.lifecycleEvent
(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent
(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start
(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start
(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start
(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start
(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start
(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start
(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.commons.daemon.support.DaemonLoader.start
(DaemonLoader.java:177)
Caused by: javax.naming.NameNotFoundException: Name mail is not bound in
this Context
at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
at org.apache.naming.SelectorContext.lookup
(SelectorContext.java:137)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
----------------------------Snip-------------------------
When I look at the resources that Tomcat recognizes through the manager
app, I see the following:
OK - Listed global resources of all types
mail/Session:javax.mail.Session
UserDatabase:org.apache.catalina.users.MemoryUserDatabase
So it looks like its there. How do I expose this to my application? I'm
sure I'm missing something obvious, but I can't seem to figure it out.
Thank you!
--
Ken T. <[email protected]>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]