users@glassfish.java.net

Re: Mail Session is not injected to member field of my bean

From: <glassfish_at_javadesktop.org>
Date: Mon, 24 Mar 2008 08:29:40 PST

Hello Cheng,

thank you for your reply. In my web.xml I added the following:

<resource-ref>
  <description>Mail Session Reference</description>
  <res-ref-name>mail/mobileMailSession</res-ref-name>
  <res-type>javax.mail.Session</res-type>
  <res-auth>Container</res-auth>
  <res-sharing-scope>Shareable</res-sharing-scope>
  <injection-target>
    <injection-target-class>
      sessionbeans.WebSessionBean
    </injection-target-class>
    <injection-target-name>
      mailSession</injection-target-name>
    </injection-target>
</resource-ref>

This worked and the mail session was injected to the member field mailSession.

Then I tried this one, because I rather would like to use annotations:

In my web.xml I now wrote:

<resource-ref>
  <description>Mail Session Reference</description>
  <res-ref-name>mail/mobileMailSession</res-ref-name>
  <res-type>javax.mail.Session</res-type>
  <mapped-name>mail/mobileMailSessionMapped</mapped-name>
</resource-ref>

And in my session bean I declared:

@Resource(name="mail/mobileMailSession", mappedName="mail/mobileMailSessionMapped" )
        private javax.mail.Session mailSession;

In this case resource injection still does not work.

Do you have any idea?

Best regards, Georg
[Message sent by forum member 'horowitznotathome' (horowitznotathome)]

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