8 Replies Latest reply on Oct 16, 2009 7:17 AM by sebastian.s

    Sending e-mails with mail tasks

    sebastian.s

      I can't send e-mails with mail tasks. In the unit tests it worked but on my Tomcat server I am getting this:

      Caused by: javax.mail.NoSuchProviderException: smtp
       at javax.mail.Session.getService(Session.java:794)
       at javax.mail.Session.getTransport(Session.java:718)
       at javax.mail.Session.getTransport(Session.java:661)
       at javax.mail.Session.getTransport(Session.java:641)
       at javax.mail.Session.getTransport(Session.java:696)
       at org.jbpm.pvm.internal.email.impl.MailSessionImpl.send(MailSessionImpl
      .java:48)
      


      I use the same configuration as for the unit test and I already checked that the SMTP-server is reachable from the box with Tomcat.

      I tried raising the loglevel but regarding this exception I don't see more ever with a higher level.

        • 1. Re: Sending e-mails with mail tasks
          kukeltje

          does tomcat contain mail.jar etc...? or maybe tomcat does not support the (JEE) mail session... just guessing here.

          • 2. Re: Sending e-mails with mail tasks
            sebastian.s

            I am going to verify tomorrow but actually it should work because this is the Tomcat demo setup supplied with the distribution, or not?

            I think it is a javax.mail or Tomcat issue. How do I get javax.mail to be a bit more verbose? Searching with Google showed up people having the same problem but most of them could see a cause for the exception.

            • 3. Re: Sending e-mails with mail tasks
              kukeltje

              Not sure how much was tested on Tomcat. Jobscheduler probably was, just like the core, but not sure if mail was included. I'd hope so, but it just might have been forgotten.

              I have no idea how to get javax.mail more verbose. Maybe running it in a debug mode (e.g. from eclipse) might help.

              • 4. Re: Sending e-mails with mail tasks
                sebastian.s

                Afaik Joram has done the integration work for Tomcat, right? Maybe I am lucky and he is going to give a statement on this. :) I searched around with Google and there are different proposals what to do. I am going to try some more things tomorrow and I'll keep you up to date here.

                • 5. Re: Sending e-mails with mail tasks
                  sebastian.s

                  Good morning,

                  I was out of luck and I did not find a solution. According to my Google search the exception javax.mailNoSuchProviderException: smtp can be thrown in a various cases:

                  * There is no mail.jar on the classpath or no smtp.jar. But this is not the case because mail.jar is on the classpath. Furthermore according to the javamail documentation mail.jar includes smtp.jar normally and you either use mail.jar packed with all the stuff needed or single jars like mailapi.jar and smtp.jar.

                  * There are several copies of the files described above in the classpath and they are of different versions. But I could not find more than one mail.jar.

                  To verify there are no problems with the jars and Tomcat I created a web application which just sends out an email using javamail and I deployed it to the server. This worked without a problem.

                  I don't know jBPM sends e-mails from mail tasks. The javamail tutorial looks up a JavaMail Session via JDNI. For my test I just used Session.getDefaultInstance(). So maybe it is something related with this?

                  Any hints?

                  I think I am going to report this as a bug or not, Ronald?

                  • 6. Re: Sending e-mails with mail tasks
                    sebastian.s

                    I tried to find a work-around for this and decided to send mails directly in a java task using javamail. I used the same code as in the web application mentioned above and I got the same exception which shows up when trying to use mail tasks. So I suppose it's a classpath issue. But which one exactly?

                    • 7. Re: Sending e-mails with mail tasks
                      kukeltje

                      there is a mail properties file as well afaik, not sure if that plays a role as well here.

                      • 8. Re: Sending e-mails with mail tasks
                        sebastian.s

                        Yes, I am aware of it and it looks like this. In build.xml you can specify the property mail.smtp.host and it is taken into account. Manually I also changed mail.from. As I said this works fine in a unit test with the same jbpm.mail.properties used.

                        mail.smtp.host=your.mail.host
                        mail.smtp.port=25
                        mail.from=noreply@jbpm.org