5 Replies Latest reply on Feb 13, 2012 8:06 AM by chufaca

    JavaMail on JBoss AS 7.1.x

    chufaca

      When I'm trying to get the session for mail notification, I receive a time out error like this:

       

      Caused by: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]

       

      The method that gave my that exception is javax.naming.Context.lookup(String name)

       

      I tried with the latest nightly build (this is really close to 7.1.0.Final)

       

      The standalone.xml for mail config is:

      <subsystem xmlns="urn:jboss:domain:mail:1.0">

                  <mail-session jndi-name="java:/Mail" debug="true">

                      <smtp-server outbound-socket-binding-ref="mail-smtp"/>

                  </mail-session>

              </subsystem>

       

      And the socket-binding-group is:

      <outbound-socket-binding name="mail-smtp">

                  <remote-destination host="localhost" port="25"/>

              </outbound-socket-binding>

       

      Has to be some config issue because I just tested it with my JBoss 5 and it works fine.

       

      Any help will be really great!

       

      Thanks in advance

       

       

      Facu

       

       

       

        • 1. Re: JavaMail on JBoss AS 7.1.x
          ctomc

          Hi,

           

          what is exact version of AS 7.1.x that you are using? there ware some bugs in CR1, all should be fixed in nightly builds after first week of january.

           

          can you paste the stacktrace?

          and you are sure that smtp is listening and accepting connection on localhost 25?

           

           

          cheers,

          tomaz

          • 2. Re: JavaMail on JBoss AS 7.1.x
            jaikiran

            Facundo Contrera wrote:

             

            Caused by: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]

             

            The method that gave my that exception is javax.naming.Context.lookup(String name)

             

            What does your jndi.properties (if any) or the InitialContext properties that you use look like?

            • 3. Re: JavaMail on JBoss AS 7.1.x
              chufaca

              There isn't any jndi.properties, I just config the standalone.xml. The Context I use is "org.jnp.interfaces.NamingContextFactory" (the same I used for jboss-5.1.0.GA).

               

              I think that the error is not because socket binding or port, or whatever... but because of that Naming Factory which doesn't recognize java:/Mail as a properly JNDI Name.

               

              I saw that in the mail-service.xml in JBoss 5 we had to add the "<depends>jboss:service=Naming</depends>", but in JBoss 7.1 I haven't configurated anything in the subsystem "naming".

               

              Does this make any sense?

              • 4. Re: JavaMail on JBoss AS 7.1.x
                ctomc

                Hi,

                 

                From where are you trying to do jndi lookup? from inside the application that is deployed in AS7?

                if that is the case you just use default NamingContextFactory. org.jnp.interfaces.NamingContextFactory does not exits anymore in AS7.

                 

                Here is sample code that will get you mail session:

                 

                InitialContext ic = new InitialContext();
                Session s = (Session)ic.lookup("java:/Mail);
                ic.close();
                

                 

                that is all of the code needed (i have omited try catch), no special InitialContext setup and passing properties

                 

                can you try this?

                 

                --

                tomaz

                1 of 1 people found this helpful
                • 5. Re: JavaMail on JBoss AS 7.1.x
                  chufaca

                  That was the error! The context in AS7 has to be "org.jboss.as.naming.InitialContextFactory" instead of "org.jnp.interfaces.NamingContextFactory".

                   

                  Thanks for all your help!