I've discovered the root to all my problems is that org.apache.james.mime4j.dom.ServiceLoader.load(Class<T>)
seems unable to load the correct instance type for the given interface eg: spiResURI: META-INF/services/org.apache.james.mime4j.dom.MessageServiceFactory resource: .../META-INF/services/org.apache.james.mime4j.dom.MessageServiceFactory [image: Inline image 1] Am not sure how this is supposed to work, the the supposed instance types seem to be null leading to strange behaviour, I'm using java jdk 6.0. On Wed, Sep 25, 2013 at 9:06 AM, Stefano Bagnara <[email protected]> wrote: > 2013/9/25 Justin Robinson <[email protected]>: > > [...] > > java.lang.ClassCastException: > org.apache.james.mime4j.message.MultipartImpl > > cannot be cast to org.apache.james.mime4j.dom.SingleBody > > at > org.apache.james.jdkim.impl.Message.getBodyInputStream(Message.java:80) > > at org.apache.james.jdkim.DKIMSigner.sign(DKIMSigner.java:85) > > This may happen if mime4j is not correctly instantiated/invoked. > mime4j has to be instructed to do raw parsing (instead of the default > multipart parsing). > > BTW I use DKIMSign mailet to sign millions messages. DKIMSign doesn't > use mime4j. > Maybe there is a bug in the mime4j parsing part. > > Are you using mime4j-0.7 ? > > > http://svn.apache.org/viewvc/james/jdkim/tags/apache-jdkim-project-0.2/main/src/main/java/org/apache/james/jdkim/impl/Message.java?view=markup > MessageServiceFactory mbf = MessageServiceFactory.newInstance(); > 70 mbf.setAttribute("MimeEntityConfig", mec); > 71 mbf.setAttribute("FlatMode", true); > 72 mbf.setAttribute("ContentDecoding", false); > > The FlatMode and ContentDecoding options are needed in order for mime4j to > work. > If they are not used or mime4j doesn't get it then you get a > MultipartImpl object and jdkim doesn't work. > > Stefano > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
