1 Reply Latest reply on Aug 20, 2008 2:27 PM by wcydaip

    JavaMail JNDI Problem

    wcydaip

      I am trying to setup the example jar from javamail1.4 within JBoss, but, I keep having problems linking my war to the appropriate JNDI value or setting the JNDI resource explicitly. I'm using JBoss4.0.3RC1

      The following is the error:

       ... 62 more
      10:39:12,031 ERROR [MainDeployer] Could not start deployment: file:/C:/jboss-4.0
      .3SP1-FRESH/server/default/deploy/javamail.war
      org.jboss.deployment.DeploymentException: Error during deploy; - nested throwabl
      e: (javax.naming.NamingException: resource-ref: MySession has no valid JNDI bind
      ing. Check the jboss-web/resource-ref.)
      


      I'm not sure what is meant by the jboss-web/resource-ref. I've taken a guess that it means a jboss-web.xml file, but, then again, I'm not sure which jboss-web.xml file I'm supposed edit.

      web.xml
       <resource-ref>
       <res-ref-name>MySession</res-ref-name>
       <res-type>javax.mail.Session</res-type>
       <jndi-name>java:/NetaMail</jndi-name>
       <res-auth>Container</res-auth>
       </resource-ref>
      


      default/deploy/mail-service.xml
       <mbean code="org.jboss.mail.MailService"
       name="jboss:service=Mail">
       <attribute name="JNDIName">java:/NetaMail</attribute>
       <attribute name="User">###</attribute>
       <attribute name="Password">###</attribute>
       <attribute name="Configuration">
       <!-- Test -->
       <configuration>
       <!-- Change to your mail server prototocol -->
       <property name="mail.store.protocol" value="imap"/>
       <property name="mail.transport.protocol" value="smtp"/>
      
       <!-- Change to the user who will receive mail -->
       <property name="mail.user" value="###"/>
      
       <!-- Change to the mail server -->
       <property name="mail.pop3.host" value="###"/>
      
       <!-- Change to the SMTP gateway server -->
       <property name="mail.smtp.host" value="###"/>
      
       <!-- Change to the address mail will be from -->
       <property name="mail.from" value="neta@###.com"/>
      
       <!-- Enable debugging output from the javamail classes -->
       <property name="mail.debug" value="true"/>
       </configuration>
       <depends>jboss:service=Naming</depends>
       </attribute>
       </mbean>
      


      and I tried the server/default/deploy/jmx-console.war/WEB-INF/jboss-web.xml
      but to no avail:
       <resource-ref>
       <res-ref-name>MySession</res-ref-name>
       <res-type>javax.mail.Session</res-type>
       <jndi-name>java:/NetaMail</jndi-name>
       <res-auth>Container</res-auth>
       </resource-ref>
      


      Can anyone tell me where I'm messing up?

      Thanks.

        • 1. Re: JavaMail JNDI Problem
          wcydaip

          Well a little more snooping payed off....

          I noticed on startup the jmx console deployment was throwing an error about finding my entry into the jboss-web.xml and not finding it in the web.xml. So that got me thinking that perhaps this war file needs a jboss-web.xml and indeed it did.

          WEB-INF
           |- web.xml
           |- jboss-web.xml
          


          Both contain:
          <resource-ref>
           <res-ref-name>java:NetaMail</res-ref-name>
           <res-type>javax.mail.Session</res-type>
           <jndi-name>java:/NetaMail</jndi-name>
           <res-auth>Container</res-auth>
           </resource-ref>
          


          And alls well that ends well...

          Thanks