[
https://issues.apache.org/jira/browse/EMAIL-155?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14599483#comment-14599483
]
Petr Osipov commented on EMAIL-155:
-----------------------------------
{quote}
Tested it with JavaMail 1.5.2 and 1.5.4 and the mail can be successfully parsed.
{quote}
I actually was using
* 'javax.mail:mail:1.4.7',
* com.sun.mail:javax.mail:1.5.4
{quote}
Are you sure that you do not have another jar in your classpath that provided
java.mail?
{quote}
This is what the *./gradlew dependecies* gives me
{noformat}
compile - Compile classpath for source set 'main'.
+--- project :generator
+--- org.slf4j:slf4j-api:1.7.6
+--- ch.qos.logback:logback-classic:1.1.2
| +--- ch.qos.logback:logback-core:1.1.2
| \--- org.slf4j:slf4j-api:1.7.6
+--- org.apache.commons:commons-csv:1.1
+--- com.impossibl.pgjdbc-ng:pgjdbc-ng:0.4
| \--- io.netty:netty-all:4.0.20.Final
+--- org.flywaydb:flyway-core:3.2.1
+--- com.sun.mail:javax.mail:1.5.4
| \--- javax.activation:activation:1.1 -> 1.1.1
+--- org.jsoup:jsoup:1.8.2
+--- org.apache.commons:commons-email:1.4
| +--- com.sun.mail:javax.mail:1.5.2 -> 1.5.4 (*)
| \--- javax.activation:activation:1.1.1
+--- org.apache.commons:commons-lang3:3.3.2
\--- commons-io:commons-io:2.4
{noformat}
So, seems like your lirbrary has a transient dependency on
*com.sun.mail:javax.mail*.
> Not Able To Parse Attachments
> -----------------------------
>
> Key: EMAIL-155
> URL: https://issues.apache.org/jira/browse/EMAIL-155
> Project: Commons Email
> Issue Type: Bug
> Environment: org.apache.commons:commons-email:1.4
> Reporter: Petr Osipov
> Priority: Critical
> Attachments: erroneous.email
>
>
> h4. Scenario
> # Sent an email from Microsoft Web UI,
> # When code tries to parse
> {code}
> public DataSource getAttachment(String username, MimeMessage mimeMessage)
> throws Exception {
> MimeMessageParser messageParser = new MimeMessageParser(mimeMessage);
> messageParser.parse();
> // further code
> }
> {code}
> An exception is thrown
> {noformat}
> java.lang.ClassCastException: javax.mail.util.SharedByteArrayInputStream
> cannot be cast to javax.mail.Multipart
> at
> org.apache.commons.mail.util.MimeMessageParser.parse(MimeMessageParser.java:195)
> at
> org.apache.commons.mail.util.MimeMessageParser.parse(MimeMessageParser.java:96)
> {noformat}
> Probably int the wild casting to javax.mail.Multipart in MimeMessageParser is
> a too brave step
> {code}
> if (isMimeType(part, "multipart/*"))
> {
> this.isMultiPart = true;
> final Multipart mp = (Multipart) part.getContent();
> final int count = mp.getCount();
> // iterate over all MimeBodyPart
> for (int i = 0; i < count; i++)
> {
> parse(mp, (MimeBodyPart) mp.getBodyPart(i));
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)