I'd like to offer the following as an addendum page for the mail component:

******

As recently as JavaMail 1.4.4, there has been an issue using JavaMail
in an OSGi framework.
This issue interferes with successful handling of multipart MIME
messages, including attachments
and HTML content.

Per the JavaMail javadoc, the content class of a
"multipart/alternative" message should be
Multipart; however, what is returned in an OSGi bundle is of class
SharedByteArrayInputStream.

This is not a Camel Mail bug, but can manifest when using the Mail
component in an OSGi framework.

>From the JavaMail project forum at kenai.com:

(http://kenai.com/projects/javamail/forums/forum/topics/13123-multipart-alternative#p27947)

It's all about ClassLoaders and the assumptions that OSGi breaks...

JavaMail (and JAF, which is the culprit in this case) uses the
ClassLoader.getResource
method to load configuration files that are contained in the JavaMail
jar file. With OSGi,
that doesn't work. So all the configuration JAF needs to find the
correct class to handle
certain MIME types is missing.

You can try using Thread.setContextClassLoader to set it to the
ClassLoader of your
application bundle. If that doesn't work, a more complicated workaround may be
required.

-- Shannon


>From the Apache Felix users mailing list:

>From Caspar MacRae <ear...@gmail.com>
Subject Re: JavaMail and Felix
Date Wed, 06 Jul 2011 09:56:05 GMT

Try adding the JavaMail (1.4.4) jar to your classpath and then put this into
the parameters for launching Felix,

org.osgi.framework.system.packages.extra=com.sun.mail.auth;version=1.4.4, \
 com.sun.mail.handlers;version=1.4.4, \
 com.sun.mail.iap;version=1.4.4, \
 com.sun.mail.imap;version=1.4.4, \
 com.sun.mail.imap.protocol;version=1.4.4, \
 com.sun.mail.pop3;version=1.4.4, \
 com.sun.mail.smtp;version=1.4.4, \
 com.sun.mail.util;version=1.4.4, \
 com.sun.mail.util.logging;version=1.4.4, \
 javax.mail;version=1.4.4, \
 javax.mail.event;version=1.4.4, \
 javax.mail.internet;version=1.4.4, \
 javax.mail.search;version=1.4.4, \
 javax.mail.util;version=1.4.4


It means you won't be able to hotdeploy JavaMail, but it should work more
like CLI wrt mailcap etc.

Reply via email to