2013/9/25 Justin Robinson <dkim-proj...@fluidnotions.com>

> 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
>

MessageServiceFactory is an abstract class so it is not the class returned.
If you don't get an exception then it must be loading the class declared in
META-INF\services\org.apache.james.mime4j.dom.MessageServiceFactory
that is org.apache.james.mime4j.message.MessageServiceFactoryImpl

BTW, can you provide a failing test case for your scenario? If not, then
maybe you have something weird in your classpath (e.g: multiple mime4j
versions).

Stefano

PS: I don't know what "Inline image 1" is from your message (the mailing
list removed it).


> [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 <apa...@bago.org> wrote:
>
>> 2013/9/25 Justin Robinson <dkim-proj...@fluidnotions.com>:
>> > [...]
>> > 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: server-dev-unsubscr...@james.apache.org
>> For additional commands, e-mail: server-dev-h...@james.apache.org
>>
>>
>

Reply via email to