users@glassfish.java.net

JNDI resource ref for MBean ?

From: <glassfish_at_javadesktop.org>
Date: Wed, 02 Jan 2008 15:45:03 PST

I'd like to send mail from within my MBean.

However, when I perform a JNDI lookup of my Glassfish JavaMail Session, I get back a MailConfiguration rather than a JavaMail Session.

            context = (Context) new InitialContext();
            Session session = (Session) context.lookup("mail/damMBeans");

I'm guessing the problem is that I haven't defined a resource-ref for my MBean; however, I don't know where to define it.

My JavaMail Session resource works fine when I do dependency injection into an EJB but this is a Glassfish MBean.


[#|2008-01-02T15:18:22.831 0800|SEVERE|sunappserver9.1|Mailer|_ThreadID=19;_ThreadName=Timer-7;_RequestID=573913a9-ef57-44ad-af75-1168947537e8;|Unable to send e-mail. java.lang.ClassCastException: com.sun.enterprise.deployment.MailConfiguration cannot be cast to javax.mail.Session
        at com.ilmn.dam.mbean.Mailer.send(Mailer.java:59)
        at com.ilmn.dam.mbean.mqDMQRetryMBeanImpl.handleNotification(mqDMQRetryM
BeanImpl.java:198)
[Message sent by forum member 'frenchdrip' (frenchdrip)]

http://forums.java.net/jive/thread.jspa?messageID=252025