Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-1261

Fatal exception when sending mail : java.lang.ClassCastException: gnu.mail.handler.TextPlain

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Critical Critical
    • mailer-plugin
    • None
    • Platform: All, OS: All

      When a build finishes, hudson fails to send a mail with the result of the build.
      This behaviour is new to version 1.180 (it worked with version 1.179).

      We get the following trace (note there is a valid e-mail and an invalid one,
      that's maybe the cause):

      Sending e-mails to: valid@email.Com ipad7251orange-ftgroup.com
      FATAL: gnu.mail.handler.TextPlain
      java.lang.ClassCastException: gnu.mail.handler.TextPlain
      at
      javax.activation.MailcapCommandMap.getDataContentHandler(MailcapCommandMap.java:596)
      at
      javax.activation.MailcapCommandMap.createDataContentHandler(MailcapCommandMap.java:550)
      at javax.activation.DataHandler.getDataContentHandler(DataHandler.java:611)
      at javax.activation.DataHandler.writeTo(DataHandler.java:315)
      at javax.mail.internet.MimeUtility.getEncoding(MimeUtility.java:248)
      at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1268)
      at javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:2012)
      at javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:1980)
      at javax.mail.Transport.send(Transport.java:97)
      at hudson.tasks.MailSender.execute(MailSender.java:74)
      at hudson.tasks.Mailer._perform(Mailer.java:75)
      at hudson.tasks.Mailer.perform(Mailer.java:69)
      at
      hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:33)
      at
      hudson.model.AbstractBuild$AbstractRunner.performAllBuildStep(AbstractBuild.java:273)
      at
      hudson.model.AbstractBuild$AbstractRunner.performAllBuildStep(AbstractBuild.java:261)
      at hudson.model.Build$RunnerImpl.post2(Build.java:136)
      at hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:246)
      at hudson.model.Run.run(Run.java:677)
      at hudson.model.Build.run(Build.java:101)
      at hudson.model.ResourceController.execute(ResourceController.java:70)
      at hudson.model.Executor.run(Executor.java:65)

      Thanks.

          [JENKINS-1261] Fatal exception when sending mail : java.lang.ClassCastException: gnu.mail.handler.TextPlain

          julienw created issue -

          Can you tell me a bit more about your environment?

          What container do you run this on? OS?

          Kohsuke Kawaguchi added a comment - Can you tell me a bit more about your environment? What container do you run this on? OS?
          Kohsuke Kawaguchi made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]

          julienw added a comment -

          We're using JRockIt R26.4.0 (based on Sun JDK 1.5.0_06), on JOnAS 4.8.4.

          To be able to install Hudson on JOnAS we added a file jonas-web.xml in hudson's
          WEB-INF directory, I'll open a separate issue for this this file must have:

          <?xml version="1.0" encoding="ISO-8859-1"?>

          <jonas-web-app xmlns="http://www.objectweb.org/jonas/ns"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://www.objectweb.org/jonas/ns
          http://www.objectweb.org/jonas/ns/jonas-web-app_4_0.xsd" >
          <java2-delegation-model>false</java2-delegation-model>
          </jonas-web-app>

          julienw added a comment - We're using JRockIt R26.4.0 (based on Sun JDK 1.5.0_06), on JOnAS 4.8.4. To be able to install Hudson on JOnAS we added a file jonas-web.xml in hudson's WEB-INF directory, I'll open a separate issue for this this file must have: <?xml version="1.0" encoding="ISO-8859-1"?> <jonas-web-app xmlns="http://www.objectweb.org/jonas/ns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.objectweb.org/jonas/ns http://www.objectweb.org/jonas/ns/jonas-web-app_4_0.xsd " > <java2-delegation-model>false</java2-delegation-model> </jonas-web-app>

          julienw added a comment -

          I tried to remove mail-1.4.jar and activation-1.1.jar from the WAR file, and it
          worked.

          Yet I don't know how you could make this a default...

          julienw added a comment - I tried to remove mail-1.4.jar and activation-1.1.jar from the WAR file, and it worked. Yet I don't know how you could make this a default...

          julienw added a comment -

          Some explanations about my last comment :
          we found that JOnAS uses the GNU implementation for javamail API and the
          activation framework. GNU Java Mail implements version 1.3 of the API whereas
          the implementation that hudson uses implements version 1.4 of the API.

          Maybe that's the reason...

          julienw added a comment - Some explanations about my last comment : we found that JOnAS uses the GNU implementation for javamail API and the activation framework. GNU Java Mail implements version 1.3 of the API whereas the implementation that hudson uses implements version 1.4 of the API. Maybe that's the reason...

          Perhaps <java2-delegation-model>false</java2-delegation-model> is wrong? This
          seems like forcing JONAS to load javamail from Hudson, not from JONAS itself.

          Kohsuke Kawaguchi added a comment - Perhaps <java2-delegation-model>false</java2-delegation-model> is wrong? This seems like forcing JONAS to load javamail from Hudson, not from JONAS itself.

          julienw added a comment -

          If you don't use this, asm is loaded from JOnAS... which is rather old.

          Indeed I think this has something to do with classloaders. But just deleting
          javamail and activation jars from Hudson's war makes Hudson use the jars in
          JOnAS, and it works correctly.

          julienw added a comment - If you don't use this, asm is loaded from JOnAS... which is rather old. Indeed I think this has something to do with classloaders. But just deleting javamail and activation jars from Hudson's war makes Hudson use the jars in JOnAS, and it works correctly.

          julienw added a comment -

          For information, I found that the bug is also in JOnAS' bugtracker (in french ):

          http://forge.objectweb.org/tracker/index.php?func=detail&aid=308797&group_id=5&atid=100005

          julienw added a comment - For information, I found that the bug is also in JOnAS' bugtracker (in french ): http://forge.objectweb.org/tracker/index.php?func=detail&aid=308797&group_id=5&atid=100005

          Filed https://glassfish.dev.java.net/issues/show_bug.cgi?id=5452 to fix
          activation.jar to handle this more gracefully.

          Hudson can then bundle such activation.jar to fix this problem.

          Kohsuke Kawaguchi added a comment - Filed https://glassfish.dev.java.net/issues/show_bug.cgi?id=5452 to fix activation.jar to handle this more gracefully. Hudson can then bundle such activation.jar to fix this problem.

            Unassigned Unassigned
            julienw julienw
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: