7 Replies Latest reply on Apr 12, 2004 2:06 PM by Brice Ruth

    JNDI access to java:/Mail from MDB

    Brice Ruth Newbie

      I'm trying to access the JavaMail provider I've configured in mail-service.xml, under java:/Mail. If I lookup "java:/Mail" in my MDB, all works fine.

      However, if I try to access "java:/comp/env/mail/MailProvider" - as I believe I've configured ejb-jar.xml and jboss.xml, then I get Naming exceptions indicating that "mail" is not bound, so obviously - my JNDI configuration in ejb-jar and jboss.xml is NOT correct.

      Here's what I have:

      ejb-jar.xml:

      <resource-ref >
       <res-ref-name>mail/MailProvider</res-ref-name>
       <res-type>javax.mail.Session</res-type>
       <res-auth>Container</res-auth>
       </resource-ref>
      

      jboss.xml:
      <resource-ref>
       <res-ref-name>mail/MailProvider</res-ref-name>
       <jndi-name>java:/Mail</jndi-name>
       </resource-ref>
      

      These are auto-generated by XDoclet via the following tags:

      * @jboss.resource-ref
      * res-ref-name = "mail/MailProvider"
      * jndi-name = "java:/Mail"
      * @ejb.resource-ref
      * res-ref-name = "mail/MailProvider"
      * res-type = "javax.mail.Session"
      * res-auth = "Container"
      

      I'm a bit at a loss here ... what's going on? jBoss 3.2.3 on WinXP.

      TIA

      --
      Brice D. Ruth
      Sr. IT Analyst
      Fiskars Brands, Inc.


        • 1. Re: JNDI access to java:/Mail from MDB
          Darran Lofthouse Master

          Have you had a look at the JNDI view in the JMX console?

          • 2. Re: JNDI access to java:/Mail from MDB
            Brice Ruth Newbie

             

            "darranl" wrote:
            Have you had a look at the JNDI view in the JMX console?


            I have now ... :)

            Under my Ejb Module (JMS Dev.jar), all I see is this:

            java:comp namespace of the MessageWriterEJB bean:
            
             +- env (class: org.jnp.interfaces.NamingContext)
            


            The only reference to "mail" anything that appear on the JNDIView page is the entry for java:/Mail.

            Should I be looking at something else? Is there something wrong with the way I've setup my ejb-jar.xml or jboss.xml?

            Any help at all is much appreciated!!

            TIA
            Brice Ruth

            • 3. Re: JNDI access to java:/Mail from MDB
              Scott Stark Master

              <p>There there is something wrong with your deployment or descriptors if there is nothing under the JNDIView. The descriptors should look like: <br/> <br/><a href="

              <?xml version="1.0"?>

              <!DOCTYPE ejb-jar PUBLIC

                 "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"

                 "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

               

              <ejb-jar>

                 <display-name>ENC Tests</display-name>

                 <enterprise-beans>

                    <session>

                       <ejb-name>ENCBean</ejb-name>

              ...

                       <!-- JavaMail Connection Factories (java:comp/env/mail) -->

                       <resource-ref>

                          <description>Default Mail</description>

                          <res-ref-name>mail/DefaultMail</res-ref-name>

                          <res-type>javax.mail.Session</res-type>

                          <res-auth>Container</res-auth>

                       </resource-ref>

                    </session>

              ...

              ">

              <?xml version="1.0"?>

              <!DOCTYPE ejb-jar PUBLIC

                 "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"

                 "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

               

              <ejb-jar>

                 <display-name>ENC Tests</display-name>

                 <enterprise-beans>

                    <session>

                       <ejb-name>ENCBean</ejb-name>

              ...

                       <!-- JavaMail Connection Factories (java:comp/env/mail) -->

                       <resource-ref>

                          <description>Default Mail</description>

                          <res-ref-name>mail/DefaultMail</res-ref-name>

                          <res-type>javax.mail.Session</res-type>

                          <res-auth>Container</res-auth>

                       </resource-ref>

                    </session>

              ...

              </a> <br/> <br/><a href="

              <?xml version="1.0" encoding="utf-8"?>

              <!DOCTYPE jboss PUBLIC

                    "-//JBoss//DTD JBOSS 3.2//EN"

                    "http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd">

               

              <jboss>

                  <enterprise-beans>

                      <session>

                          <ejb-name>ENCBean</ejb-name>

                          <resource-ref>

                              <res-ref-name>mail/DefaultMail</res-ref-name>

                              <resource-name>DefaultMail</resource-name>

                          </resource-ref>

                      </session>

                  </enterprise-beans>

              </jboss>

              ">

              <?xml version="1.0" encoding="utf-8"?>

              <!DOCTYPE jboss PUBLIC

                    "-//JBoss//DTD JBOSS 3.2//EN"

                    "http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd">

               

              <jboss>

                  <enterprise-beans>

                      <session>

                          <ejb-name>ENCBean</ejb-name>

                          <resource-ref>

                              <res-ref-name>mail/DefaultMail</res-ref-name>

                              <resource-name>DefaultMail</resource-name>

                          </resource-ref>

                      </session>

                  </enterprise-beans>

              </jboss>

              </a> <br/></p>

              • 4. Re: JNDI access to java:/Mail from MDB
                Brice Ruth Newbie

                OK, I'm still not seeing anything. In jboss.xml, in the <resource-ref>...</resource-ref> for my MDB, what is the resource-name supposed to refer to? If the JNDIName I've defined for mail-service.xml is java:/Mail, is resource-name supposed to be 'Mail' or java:/Mail, or something else?

                Also, in JNDIView, am I supposed to see these entries under the java:comp namespace of my EJB? That would be my assumption ... Right now, all I see listed for my EJB is 'env' -

                java:comp namespace of the MessageWriterEJB bean:
                
                 +- env (class: org.jnp.interfaces.NamingContext)


                I very much appreciate any and all help in getting to the bottom of this ... and many thanks for being patient with a newbie!

                Here's what I have now:

                jboss.xml:
                <?xml version="1.0" encoding="UTF-8"?>
                <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 2.4//EN" "http://www.jboss.org/j2ee/dtd/jboss_2_4.dtd">
                
                <jboss>
                 <enterprise-beans>
                 <message-driven>
                 <ejb-name>MessageWriterEJB</ejb-name>
                <destination-jndi-name>queue/BricesQueue</destination-jndi-name>
                 <resource-ref>
                 <res-ref-name>mail/MailProvider</res-ref-name>
                 <resource-name>Mail</resource-name>
                 </resource-ref>
                 </message-driven>
                 </enterprise-beans>
                 <resource-managers>
                 </resource-managers>
                </jboss>
                


                ejb-jar.xml:
                <?xml version="1.0" encoding="UTF-8"?>
                <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
                
                <ejb-jar >
                
                 <description>[CDATA[No Description.]]</description>
                 <display-name>Generated by XDoclet</display-name>
                
                 <enterprise-beans>
                
                 <!-- Message Driven Beans -->
                 <message-driven >
                 <description>[CDATA[MessageWriterBean EJB]]</description>
                 <display-name>MessageWriterEJB</display-name>
                
                 <ejb-name>MessageWriterEJB</ejb-name>
                
                 <ejb-class>msg.ejb.MessageWriterBean</ejb-class>
                
                 <transaction-type>Container</transaction-type>
                 <message-driven-destination>
                 <destination-type>javax.jms.Queue</destination-type>
                 </message-driven-destination>
                
                 <resource-ref >
                 <res-ref-name>mail/MailProvider</res-ref-name>
                 <res-type>javax.mail.Session</res-type>
                 <res-auth>Container</res-auth>
                 </resource-ref>
                
                 </message-driven>
                
                 </enterprise-beans>
                
                 <!-- Assembly Descriptor -->
                 <assembly-descriptor >
                 <!-- finder permissions -->
                
                 <!-- transactions -->
                
                 <!-- finder transactions -->
                 </assembly-descriptor>
                
                </ejb-jar>
                


                • 5. Re: JNDI access to java:/Mail from MDB
                  Brice Ruth Newbie

                  Any additional assistance on this topic would be much appreciated!

                  • 6. Re: JNDI access to java:/Mail from MDB
                    Raja Master

                     

                    "bruth" wrote:
                    I'm trying to access the JavaMail provider I've configured in mail-service.xml, under java:/Mail. If I lookup "java:/Mail" in my MDB, all works fine.

                    However, if I try to access "java:/comp/env/mail/MailProvider" - as I believe I've


                    Shouldnt this be java:comp/env/mail/MailProvider?
                    or is this a typo?



                    • 7. Re: JNDI access to java:/Mail from MDB
                      Brice Ruth Newbie

                       

                      "raja05" wrote:
                      "bruth" wrote:
                      I'm trying to access the JavaMail provider I've configured in mail-service.xml, under java:/Mail. If I lookup "java:/Mail" in my MDB, all works fine.

                      However, if I try to access "java:/comp/env/mail/MailProvider" - as I believe I've


                      Shouldnt this be java:comp/env/mail/MailProvider?
                      or is this a typo?



                      I can give this a shot, but since I'm not seeing anything in JNDIView for "MailProvider" - I'm not sure if it'll make a difference!! It seems like something's still wrong with my ejb-jar.xml and/or jboss.xml.