3 Replies Latest reply on Nov 21, 2011 4:32 PM by Bill Shannon-Oracle

    ParseException while executing the MimeMultipart.getCount method

    Saroja Kandepuneni-Oracle
      When processing the multipart of a MIME message having Content-Type as
      Content-Type: multipart/related;
      boundary="Apple-Mail=_EE1C9EA8-4C44-4DF4-85CC-6DE4EB3DA902"; type=text/html

      we observed that MimeBodyPart.isMimeType("multipart/*") is returning false.
      Then we changed the condition to message.getContentType.startsWith("multipart/") to continue further processing.
      Then we got the ParseException as shown below from MimeBodyPart.getCount( ..)

      javax.mail.internet.ParseException: Expected ';', got "/"
           at javax.mail.internet.ParameterList.<init>(ParameterList.java:179)
           at javax.mail.internet.ContentType.<init>(ContentType.java:100)
           at javax.mail.internet.MimeMultipart.parsebm(MimeMultipart.java:651)
           at javax.mail.internet.MimeMultipart.parse(MimeMultipart.java:383)
           at javax.mail.internet.MimeMultipart.getCount(MimeMultipart.java:229)
           at oracle.apps.fnd.wf.mailer.EmailParser.parseBody(EmailParser.java:2529)
           at oracle.apps.fnd.wf.mailer.EmailParser.parseEmail(EmailParser.java:1422)
           at oracle.apps.fnd.wf.mailer.IMAPResponseHandler.processSingleMessage(IMAPResponseHandler.java:255)
           at oracle.apps.fnd.wf.mailer.IMAPResponseHandler.processMessage(IMAPResponseHandler.java:92)
           at oracle.apps.fnd.cp.gsc.SvcComponentProcessor.process(SvcComponentProcessor.java:659)
           at oracle.apps.fnd.cp.gsc.Processor.run(Processor.java:283)
           at java.lang.Thread.run(Thread.java:662)

      After referring to rfc 2387 (http://www.ietf.org/rfc/rfc2387.txt) we found that the Content-Type parameter 'type' value should be
      enclosed within quotes as it contains the '/' which is a special character.
      After enclosing the type value in quotes ( type="text/html"),
      the MIME message was processed successfully.

      We don't have control on the MIME contents that we get, how we can resolve these kind of issues?
      And also one more question the Content-Type value 'multipart/related' has also special character which is not enclosed in double quotes,
      but error was not thrown. Why the error is throwing for 'type' parameter value.
      Please advice.
        • 1. Re: ParseException while executing the MimeMultipart.getCount method
          Bill Shannon-Oracle
          See the package javadocs for the javax.mail.internet package for all the properties you can set to control things like this.
          In particular, the System property mail.mime.parameters.strict can be set to false to better handle incorrectly formatted

          And of course when you discover such an incorrectly formatted message, you should always report the bug to the owner
          of the software that created the message.

          To determine what needs to be quoted where and how, you need to read the detailed syntax requirements in the specs.
          Guessing the rules by inference or analogy doesn't work.
          1 person found this helpful
          • 2. Re: ParseException while executing the MimeMultipart.getCount method
            Saroja Kandepuneni-Oracle
            Hi bshannon ,

            Thanks for your reply.
            I set the system property "mail.mime.parameters.strict" to false as below in our code.
            System.setProperty("mail.mime.parameters.strict", "false");

            But still I see the same error "javax.mail.internet.ParseException: Expected ';', got "/""
            I tried to log the System property 'mail.mime.parameters.strict' before setting to false as below

            But this was returning null, but this should return true by default, which means that property not exists.

            Can you let me know in which java Mail API this property is introduced.
            I tried even with latest 1.4.4 API, still the same issue.
            • 3. Re: ParseException while executing the MimeMultipart.getCount method
              Bill Shannon-Oracle
              You have to be sure to set the System property before the JavaMail classes that use it are loaded.
              If you're running in an application server, for instance, you may need to set it when the application
              server starts up, not when your application starts.

              The property was introduced in JavaMail 1.4.2.

              You can test the use of this property by saving the message to a file and using the msgshow.java
              demo program to read the file. Set the property on the command line when running the program.
              If that still doesn't work, send me a copy of the message that isn't parsed correctly at javamail_ww@oracle.com.