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

ClassCastException when storing multipart message without Msg ID

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Invalid
    • 2.3.0
    • 2.3.0
    • None

    Description

      This problem occurs with James HEAD, but not with James 2.2.0

      When sending a multipart message which has no Message-ID header field to an internal user, the following exception is raised:

      javax.mail.MessagingException: Exception caught while storing Message Container: javax.mail.MessagingException: MIME part of type "multipart/mixed; boundary="bmQykoPt9wvlXeBFetOZnNCi/trubV+f25KeVm5YJYo="" contains object of type com.sun.mail.util.SharedByteArrayInputStream instead of MimeMultipart
      at org.apache.james.mailrepository.AvalonMailRepository.store(AvalonMailRepository.java:329)
      at org.apache.james.transport.mailets.ToMultiRepository.storeMail(ToMultiRepository.java:226)
      at org.apache.james.transport.mailets.ToMultiRepository.service(ToMultiRepository.java:151)
      at org.apache.james.transport.mailets.LocalDelivery.service(LocalDelivery.java:64)
      at org.apache.james.transport.LinearProcessor.service(LinearProcessor.java:414)
      at org.apache.james.transport.JamesSpoolManager.process(JamesSpoolManager.java:397)
      at org.apache.james.transport.JamesSpoolManager.run(JamesSpoolManager.java:306)
      at java.lang.Thread.run(Thread.java:534)

      the exception is thrown within JavaMail, the last related James call is in line 67 of MimeMessageUtil:

      public static void writeTo(MimeMessage message, OutputStream headerOs, OutputStream bodyOs, String[] ignoreList) throws IOException, MessagingException {
      if (message instanceof MimeMessageCopyOnWriteProxy) {
      MimeMessageCopyOnWriteProxy wr = (MimeMessageCopyOnWriteProxy) message;
      MimeMessage m = wr.getWrappedMessage();
      if (m instanceof MimeMessageWrapper)

      { MimeMessageWrapper wrapper = (MimeMessageWrapper)m; wrapper.writeTo(headerOs, bodyOs, ignoreList); return; }

      } else if (message instanceof MimeMessageWrapper)

      { MimeMessageWrapper wrapper = (MimeMessageWrapper)message; wrapper.writeTo(headerOs, bodyOs, ignoreList); return; }

      if(message.getMessageID() == null)

      { message.saveChanges(); //// <====== exception thrown from here }

      the exception is going away if at least one of the following is done:
      + a message id header field is added when sending the message
      + the receiver is not a James internal account
      + the message mime type is changed from "multipart" to something else
      + James 2.2.0 is being used.

      I did the first one for the stress test tool, but wonder if a Message-ID is mandatory.
      I debugged this problem but did not find neither a fix nor the critical change from 2.2.0

      Attachments

        1. MimeMessageUtilTest.java
          4 kB
          Stefano Bagnara
        2. test.zip
          2 kB
          Bernd Fondermann

        Activity

          People

            bago Stefano Bagnara
            brainlounge Bernd Fondermann
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: