Uploaded image for project: 'James Server'
  1. James Server
  2. JAMES-1431

Geronimo JavaMail implementation throws exception when opening content of an image attachment

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.0-beta4
    • None
    • None
    • Linux Fedora 14

    Description

      When image files (Content-Type: image/gif, image/jpeg, image/jpg) are attached to emails and
      Apache James 3.0 Beta4 serves as an MTA I am getting these exceptions on MimeBodyPart.getContent() calls below (while processing the mail within the attached
      test.mailet.BodyPartExtractingMailet mailet). This is due to the fact that as of Apache James Beta4
      it ships with Geronimo JavaMail implementation (geronimo-javamail_1.4_mail-1.6.jar) that is the cause
      of this exception (with Apache James Beta3 Oracle JavaMail implementation (mail-1.4.4.jar) handled
      this correctly without exceptions).

      Precise steps to reproduce :

      1. Deploy the attached test.mailet.BodyPartExtractingMailet to run within Apache James Beta4

      a. package it as a jar and put it under JAMES/lib
      b. add <mailet match="All" class="test.mailet.BodyPartExtractingMailet"/> to
      JAMES/conf/mailetcontainer.conf
      c. add log4j.logger.test.mailet.BodyPartExtractingMailet=DEBUG, CONS, FILE to
      JAMES/conf/log4j.properties
      d. (re-) start James, tailing -f either JAMES/log/mailetcontainer.log or JAMES/bin/wrapper.log

      2. Using your favorite email client send an email to yourself (with Apache James processing
      your email) containing attachments with MimeTypes image/jpeg, image/jpg and image/gif
      (surprisingly enough image/png is handled without an exception). You can use attached
      btnbg_over.jpg and up_15x15.gif.

      3. Observe these exceptions in the log file

      spooler-1 | INFO | 11:51:14,807 08/13/2012 | mailetcontext | service() start
      spooler-1 | INFO | 11:51:14,866 08/13/2012 | mailetcontext | BodyPart with an image MimeType [image/gif;
      name="up_15x15.gif"] found, BEFORE calling getContent() on it.
      spooler-1 | INFO | 11:51:14,940 08/13/2012 | mailetcontext | Exception is thrown during MimeBodyPart.getContent() call
      javax.activation.UnsupportedDataTypeException: Unknown image type image/gif;
      name="up_15x15.gif"
      at org.apache.geronimo.javamail.handlers.AbstractImageHandler.getContent(AbstractImageHandler.java:57)
      at javax.activation.DataSourceDataContentHandler.getContent(DataHandler.java:790)
      at javax.activation.DataHandler.getContent(DataHandler.java:537)
      at javax.mail.internet.MimeBodyPart.getContent(MimeBodyPart.java:637)
      at test.mailet.BodyPartExtractingMailet.service(BodyPartExtractingMailet.java:51)
      at org.apache.james.mailetcontainer.impl.camel.CamelProcessor.process(CamelProcessor.java:65)
      ...
      spooler-1 | INFO | 11:51:14,945 08/13/2012 | mailetcontext | BodyPart with an image MimeType [image/png;
      name="arrow_down_8x8.png"] found, BEFORE calling getContent() on it.
      spooler-1 | INFO | 11:51:14,961 08/13/2012 | mailetcontext | BodyPart with an image MimeType found, AFTER calling getContent() on it.
      spooler-1 | INFO | 11:51:14,961 08/13/2012 | mailetcontext | BodyPart with an image MimeType [image/jpeg;
      name="btnbg_over.jpg"] found, BEFORE calling getContent() on it.
      spooler-1 | INFO | 11:51:14,962 08/13/2012 | mailetcontext | Exception is thrown during MimeBodyPart.getContent() call
      javax.activation.UnsupportedDataTypeException: Unknown image type image/jpeg;
      name="btnbg_over.jpg"
      at org.apache.geronimo.javamail.handlers.AbstractImageHandler.getContent(AbstractImageHandler.java:57)
      at javax.activation.DataSourceDataContentHandler.getContent(DataHandler.java:790)
      at javax.activation.DataHandler.getContent(DataHandler.java:537)
      at javax.mail.internet.MimeBodyPart.getContent(MimeBodyPart.java:637)
      at test.mailet.BodyPartExtractingMailet.service(BodyPartExtractingMailet.java:51)
      at org.apache.james.mailetcontainer.impl.camel.CamelProcessor.process(CamelProcessor.java:65)
      ...
      spooler-1 | INFO | 11:51:14,968 08/13/2012 | mailetcontext | service() end

      Note #1: removing geronimo-javamail_1.4_mail-1.6.jar from the classpath fixes the problem (ie, no
      exceptions are thrown). However, you can't just comment the line out
      wrapper.java.classpath.88=%REPO_DIR%/geronimo-javamail_1.4_mail-1.6.jar
      in JAMES/conf/wrapper.conf as all jars after this line will be lost (as they are expected to be in order); hence just set the JavaMail (mail-1.4.4.jar) which was already set up earlier (as Classpath argument 10) ... as also jar argument 88
      wrapper.java.classpath.88=%REPO_DIR%/mail-1.4.4.jar
      ).

      Note #2: This issue might be documented in https://issues.apache.org/jira/browse/GERONIMO-5415
      and was supposedly fixed in geronimo-javamail_1.4_mail-1.8.1.jar (however Apache James Beta4 is using an older geronimo-javamail_1.4_mail-1.6.jar). I don't know whether Apache James really needs
      geronimo-javamail implementation as Oracle's JavaMail (ie. mail-1.4.4.jar) seems to handle this
      correctly.

      Attachments

        1. BodyPartExtractingMailet.java
          3 kB
          Idea Harness
        2. up_15x15.gif
          0.1 kB
          Idea Harness
        3. arrow_down_8x8.png
          0.2 kB
          Idea Harness
        4. btnbg_over.jpg
          0.4 kB
          Idea Harness
        5. geronimo-javamail_1.4_mail-1.8.3.jar
          453 kB
          Idea Harness

        Activity

          People

            eric@apache.org Eric Charles
            idea.harness Idea Harness
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: