This question is related to my recent question on mailing log messages.
We're attempting to send log messages via mail, with a custom log handler. As an alternative to creating our own session, it occurred to us that we might use a JavaMail session configured in GlassFish. We create a JavaMail session in the console, giving it the name "mail/loggingMailSession". But then we find we are not able to look that session up from an installed log handler.
Our custom log handler is based on smtphandler-0.7. It does not attempt to inject the session; instead it performs a context lookup. We have tried many combinations of JNDI scope, but none of them find the configured session:
java:comp/env/mail/loggingMailSession
java:global/env/mail/loggingMailSession
java:global/mail/loggingMailSession
mail/loggingMailSession
...ad nauseum
Questions: Is it possible to lookup and load a JavaMail session in JNDI from a log handler? If so, what name should we use for the lookup?