You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Steve Widmar <SW...@irf.com> on 2005/12/17 07:31:43 UTC
Tomcat 5.5.12: custom mail resource property values ignored in META-INF\context.xml
I'm trying to configure a mail server resource,
but I can't seem to get tomcat to honor the custom property values I've
provided.
In short, it uses [localhost] as the mail.smtp.host even if I set it to
something else (my actual smtp server).
Here's the details:
My META-INF\context.xml:
<Context reloadable="true" antiResourceLocking="true" override="true">
<Resource name="mail/Session2" auth="Container"
type="javax.mail.Session"
mail.smtp.host="smtp.bogus-domain.com" mail.smtp.auth="true"
mail.smtp.user="me@bogus-domain.com" password="myPassword"
mail.from="myapp@other-fake-domain.com"/>
</Context>
(tried this without @override, and also like:
<Resource name="mail/Session2" auth="Container"
type="javax.mail.Session" />
<ResourceParams name="mail/Session2">
<parameter>
<name>mail.smtp.host</name>
<value>smtp.bogus-domain.com</value>
</parameter>
... etc ...
</ResourceParams>
)
My WEB-INF\web.xml:
<resource-ref>
<res-ref-name>mail/Session2</res-ref-name>
<res-type>javax.mail.Session</res-type>
<res-auth>Container</res-auth>
</resource-ref>
The relevant code snippet:
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
Session session = (Session) envCtx.lookup("mail/Session2");
java.util.Properties sessProps = session.getProperties();
java.util.Enumeration propNames = sessProps.propertyNames();
while(propNames.hasMoreElements()) {
String propName = (String) propNames.nextElement();
String propValue = sessProps.getProperty(propName);
logger.debug("["+propName+"="+propValue+"]");
}
MimeMessage message = new MimeMessage(session);
message.setRecipients(Message.RecipientType.BCC,
"me@bogus-domain.com");
message.setSubject("subject");
String messageText = "This is the \n message content";
message.setText(messageText);
Transport.send(message);
The relevant console trace:
1672 [http-55120-Processor25] [mail.transport.protocol=smtp]
1672 [http-55120-Processor25] [scope=Shareable]
1672 [http-55120-Processor25] [mail.smtp.host=localhost]
1672 [http-55120-Processor25] [auth=Container]
2674 [http-55120-Processor25] Could not connect to SMTP host:
localhost, port: 25;
(... Exception stack trace)
I'm running tomcat 5.5.12.
Also,
no changes to $CATALINA_HOME/conf/context.xml
no $CATALINA_HOME/conf/[enginename]/[hostname]/context.xml.default
exists
I've checked the docs, searched the archives and googled, still stuck.
Can anyone point out where I went astray (on this issue; not in life in
general :-P),
and what should I do different to make it work?
Also, where could I find a DTD-like explanation of the available
properties for this resource type?
Cheers,
Steve
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org