P.S. I'm using jdk 1.5.0_04 with Eclipse 3.1 and WTP 0.7 with Spring
1.2.2 as my dev environment.
Brian
Brian Bonner wrote:
Hello, I'm trying to use the
org.apache.naming.factory.MailSessionFactory in 5.5.9 with Spring's
JndiObjectFactoryBean and I'm experiencing problems. I want to
configure a global mail configuration and then use a resource-link to
link one or more apps to the resource.
i.e.
<Resource name="GlobalMailSession" auth="Container"
type="javax.mail.Session" description="Global Mail Session"
mail.smtp.user="xyz" password="dummy" >
</Resource>
The GlobalLifecycleListener creates these MBeans (and the appropriate
javax.mail.Authenticator)
Unfortunately, however, I can't specify the smtp.mail.host, port,
protocol or localhost with this resource definition. smtp.mail.host
defaults to localhost.
When I want to access the mailSession using Spring, doing a lookup
causes a new MailSession to be created with the settings of the
ResourceReference (i.e. the Authenticator is null).
<bean id="mailSession"
class="org.springframework.jndi.JndiObjectFactoryBean"
singleton="true">
<property name="jndiName">
<value>mail/MailSession</value>
</property>
<property name="resourceRef">
<value>true</value>
</property>
<property name="javaMailProperties">
<props>
<prop key="mail.smtp.port">25</prop>
<prop key="mail.transport.protocol">smtp</prop>
<prop key="mail.smtp.host">mymailhost</prop>
</props>
</property>
</bean>
My Web.xml's resource-ref is as follows:
<resource-ref>
<description>Mail Session</description>
<res-ref-name>mail/MailSession</res-ref-name>
<res-type>javax.mail.Session</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
My context.xml (that I'm definining in the META-INF directory) includes:
<ResourceLink name="mail/Session"
global="GlobalMailSession"
type="javax.mail.Session" />
So, I have the properties for port, protocol, and localhost, but the
Authenticator is gone. Argh!
I've seen other folks have problems with this in 5.5. Looking at the
source suggests that this Factory needs some work. I looked at the
5.5.10 changelog and it doesn't show any changes to this code AFAIK.
So my quick questions are:
1. The ResourceParams tag doesn't appear to be supported any longer
in Tomcat 5.5.x. (they were supported in 4.1.x, but I can't even find
reference to them). How do I define the localhost as well as
authentication for a global MailSessionFactory resource?
2. How do I prevent a new resource being created in 5.5.x each
time--why can't I get to the original global resource? Is there a
switch I forgot to throw?
Thanks.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]