4 Replies Latest reply on Feb 6, 2005 1:00 PM by Adrian Brock

    JavaMail in JBoss

    stevecoh2 Newbie

      I am working on an application which I did not code that runs under JBoss 3.2.x and I am having very some very strange experiences with it.

      The application at several points sends Email. This sending of email is handled by a stateless session EJB that was written here but not by me. Basically the bean is passed a value object containing all relevant data to the email, to addresses, from addresses, attachments, etc. It puts all this data into a MimeMessage object, and then, when that is done, sends it off by calling Transport.send() on the MimeMessage. It all mostly works, in spite of the fact that we have never configured our mail-service.xml in any way. I suppose that had we relied on the config, some of our code might have been simplified and various addresses could have been defaulted in.

      The problem comes in here. Email messages within our company's domain which are validly formatted but actually non-existent addresses, a SendFailedException is thrown with a message of
      User unknown at javax.mail.Transport.send0(Transport.java:218)
      Now what makes this really wierd, is that our code has a catch block to catch this exception, log it, and then wrap it in an app-specific exception and throw that wrapped exception.

      This is percolating out to our presentation layer, but what is shown there is NOT the wrapper exception we threw, but the SendFailedException all over again. Where the heck did THAT come from. We caught that exception. It's almost as if Transport is throwing more exceptions asynchronously. Has anyone ever seen behavior like this and is there anything we can do to correct it, perhaps with changes to mail-service.xml?

        • 1. Re: JavaMail in JBoss
          stevecoh2 Newbie

          OK. Several have read, nobody has answered. I'm not complaining, nobody felt they had an answer.

          So I've been digging in the bowels of jboss source to try to understand. What I'm finding is that jboss is possibly not defined at all. Since javax.mail.Transport is an abstract class, I was just assuming that JBoss defined a concrete implementation that was somehow linked in. But that doesn't appear to be the case at all. There does not appear to be any class in JBoss that inherits from Transport. Instead, the JBoss mechanism appears to be a way to create a service that somehow interacts with the Transport layer without defining a concrete implementation.

          So then, how does it work at all?
          Let me ask a simpler question, even outside of the JBoss realm:
          Transport.send() is a static wrapper around the real implementation. If you've done nothing to define a concretel implementation, what concrete implementation is Transport.send() calling? Sun's javadocs are completely mum about this.



          • 2. Re: JavaMail in JBoss
            stevecoh2 Newbie

            oops, I mean to say "What I'm finding is that jboss is possibly not involved at all".

            • 3. Re: JavaMail in JBoss
              Adrian Brock Master

              Correct

              JBOSS_HOME/server/default/lib/mail.jar and mail-plugin.jar is the Sun provided
              reference implementation

              You will never get any answers to your questions if you just post words (your assertions about what you *think* is happening).
              You will be ignored unless you post code/config/exceptions/logging (we need to see what
              is really happening).

              • 4. Re: JavaMail in JBoss
                Adrian Brock Master

                Your problem with not seeing the exceptions being caught is clearly not a JBoss issue.

                It is either:
                1) A serious bug with your java compiler/jvm (very unlikely) - better targeted at your jdk provider
                2) You are running code that is NOT compiled from the source you are looking at
                3) You are not catching that exception you think you are
                4) It is not being thrown from the location where you think it is thrown from

                This whole question is better targetted at a beginners java forum rather than
                the JBoss forums. Then you wonder why you are ignored here?