multipart/alternative

  6 posts   Feedicon  
Replies: 5 - Last Post: July 06, 2011 04:48
by: shannon
showing 1 - 6 of 6
 
Posted: July 05, 2011 16:35 by dwhytock
Hi all...

Trying to handle messages coming in with a content-type of "multipart/alternative". What I get from Message.getContent() is a javax.mail.util.SharedByteArrayInputStream, where according to the javadoc I should be getting a javax.mail.Multipart.

Is "multipart/alternative" handled by the current API?

Thanks...

Don
 
Posted: July 05, 2011 17:34 by shannon
Yes, it's handled.

There's probably something wrong in your setup that is causing this to fail.

Do regular multipart/mixed messages work as expected?

What environment is your code running in? A standalone Java application? An application server?

What version of JavaMail are you using, and what version of the JDK are you using?
 
Posted: July 05, 2011 18:07 by dwhytock
I haven't been able to get regular attachments either.

My code is in an OSGi bundle, running under Apache Felix 3.0.8.

I'm using JavaMail 1.4.4, running with Java 1.6.0_06.
 
Posted: July 05, 2011 18:09 by dwhytock
BTW, I'm able to receive "text/plain" messages with no problem.
 
Posted: July 05, 2011 20:36 by dwhytock
Okay, I tried a plain application structured as an OSGi bundle. Running it standalone I see MimeMultipart. Running it in Felix I see SharedByteArrayInputStream.

The mailapi bundle doesn't complain on startup, so I assume it's able to find javax.activation.

Is there maybe a configuration file, something in javaee.jar or mailapi.jar, that DataHandler can't get to in an OSGi environment?
 
Posted: July 06, 2011 04:48 by shannon
Sigh. It's more complicated than that, and I haven't had time to implement the solution.

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.
showing 1 - 6 of 6
Replies: 5 - Last Post: July 06, 2011 04:48
by: shannon
  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2010, Oracle Corporation and/or its affiliates
(revision 20120518.3c65429)
 
 
Close
loading
Please Confirm
Close