users@glassfish.java.net

Re: Problem on configuring Java Mail Session

From: <glassfish_at_javadesktop.org>
Date: Fri, 21 Mar 2008 17:13:41 PST

Hi Sahoo,

Thanks for that. The @Resource at class level works either.

Can I ask you a further question on this, that is how to work it out using deployment descriptor instead? Below are ejb-jar.xml and sun-ejb-jar.xml I am using, when I added them into your example and commented out the @Resource annotation, I got both a and b are MailConfiguration, not the desired MailSession.
Can you please have a look and let me know if I did something wrong?
ejb-jar.xml
<?xml version="1.0" encoding="UTF-8"?>

<ejb-jar xmlns = "http://java.sun.com/xml/ns/javaee"
         version = "3.0"
         xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">
    <enterprise-beans>
        <session>
            <ejb-name>VisitorRegistrationService</ejb-name>
            <ejb-class>ejb.VisitorRegistrationService</ejb-class>
            <resource-env-ref>
                <resource-env-ref-name>mail/MailSession</resource-env-ref-name>
                <resource-env-ref-type>javax.mail.Session</resource-env-ref-type>
                
            </resource-env-ref>
        </session>
    </enterprise-beans>
</ejb-jar>

sun-ejb-jar.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 EJB 3.0//EN" "http://www.sun.com/software/appserver/dtds/sun-ejb-jar_3_0-0.dtd">
<sun-ejb-jar>
  <enterprise-beans>
      <ejb>
          <ejb-name>VisitorRegistrationService</ejb-name>
          <jndi-name>VisitorRegistrationService</jndi-name>
          <resource-env-ref>
              <resource-env-ref-name>mail/MailSession</resource-env-ref-name>
              <jndi-name>mail/FossDemoMailSession</jndi-name>
          </resource-env-ref>
      </ejb>
  </enterprise-beans>
</sun-ejb-jar>


Thanks
Ken
[Message sent by forum member 'dabaner' (dabaner)]

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