Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
None
-
None
-
$ java -version
java version "1.6.0_30"
Java(TM) SE Runtime Environment (build 1.6.0_30-b12)
Java HotSpot(TM) 64-Bit Server VM (build 20.5-b03, mixed mode)Slackware 13.37 64 bit
Linux 2.6.38.4 x86_64
-
Patch Available
Description
I am using the service mix javax.activation and javax.mail bundles:
<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.javax.mail</artifactId>
<version>1.4.1_5</version>
</dependency>
<dependency>
<groupId>org.apache.servicemix.specs</groupId>
<artifactId>org.apache.servicemix.specs.activation-api-1.1</artifactId>
<version>1.9.0</version>
</dependency>
For various reasons I am also using:
<dependency>
<groupId>org.ops4j.pax.web</groupId>
<artifactId>pax-web-jetty-bundle</artifactId>
<version>1.1.2</version>
</dependency>
That bundle includes java-mail and activation as part of the bundle itself and
also includes a mailcap file. The
org.apache.servicemix.specs.activation.Activator picks that up and adds the
mailcap entries to the OsgiMailcapCommandMap.
$ unzip -q -c pax-web-jetty-bundle-1.1.2.jar META-INF/mailcap
#
- @(#)mailcap 1.8 05/04/20
# - Default mailcap file for the JavaMail System.
# - JavaMail content-handlers:
#
text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain
text/html;; x-java-content-handler=com.sun.mail.handlers.text_html
text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml
multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed; x-java-fallback-entry=true
message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822
# - can't support image types because java.awt.Toolkit doesn't work on servers
#
#image/gif;; x-java-content-handler=com.sun.mail.handlers.image_gif
#image/jpeg;; x-java-content-handler=com.sun.mail.handlers.image_jpeg
When I then try to send a multipart email, the DataContentHandler comes from
the pax-web-jetty-bundle, but that instance comes from its classloader and is
not assignable to the DataContentHandler as seen by the
org.apache.servicemix.specs.activation-api-1.1 bundle. This results in a
ClassCastException on line 60 in OsgiMailcapCommandMap which propagates up the
call stack.
I'll attached a patch which fixes the problem for me and an example stack
trace.