Thanks for you reply.
Using "java:comp/env" as prefix didn't work, the application would encounter name not found exception. Actually using lookup("mail/MyMail") had found the resource but it failed to instantiate the Session object due to something else e.g. ClassCasting exception as the resource was recognized as mail configuration etc.
I am assuming in the scenario of dependency injection Glassfish might have done something internally convert the "MailConfiguration" to mail Session, but more likely in the JNDI scenario the convertion Glassfish has left the conversion to application developer! I don't think this is desirable for both Glassfish and application developer, please correct me if I have missed something.
Please note that, I have also tried using following code, it didn't work either,
@Resource (name="mail/MyMail")
public class MyMailerBean {
@Resource SessionContext ctx;
public void sendMail(){
javax.mail.Session session = (javax.mail.Session)ctx.lookup("mail/MyMail");
......
[Message sent by forum member 'dabaner' (dabaner)]
http://forums.java.net/jive/thread.jspa?messageID=263770