Jay
Jay

Reputation: 1422

java.lang.NoSuchMethodError when sending mail using Apache James 3

I just downloaded and setup the Apache James 3 latest beta release on Windows and so far i haven't been able to send a simple message. It looks like there is an issue with the build. The error is -

ERROR 22:45:01,666 | james.mailspooler | Exception processing mail while spooling Unable to process mail Mail1442234701295-757cd62b-eeed-4671-828c-2a7c715acfaa (org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[Message: org.apache.james.core.MailImpl@4262d5d7])
javax.mail.MessagingException: Unable to process mail Mail1442234701295-757cd62b-eeed-4671-828c-2a7c715acfaa (org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[Message: org.apache.james.core.MailImpl@4262d5d7])
.
.
Caused by: javax.mail.MessagingException: Unable to process mail Mail1442234701295-757cd62b-eeed-4671-828c-2a7c715acfaa (org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[Message: org.apache.james.core.MailImpl@4262d5d7])
.
.
Caused by: org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[Message: org.apache.james.core.MailImpl@4262d5d7]
.
.
Caused by: java.lang.NoSuchMethodError: org.apache.james.mime4j.stream.MimeConfig: method <init>()V not found

The relevant class in the JAR shows the supposedly missing constructor so i am at a complete loss. Can anyone guide me in the right direction please?

Thanks in advance!

Edit: Decompiled code snippet from the MimeConfig class shows the constructor

public final class MimeConfig {
  /* member class not found */
  class Builder {}
.
.
  MimeConfig(boolean strictParsing, int maxLineLen, int maxHeaderCount, int maxHeaderLen, long maxContentLen, boolean countLineNumbers, 
                String headlessParsing, boolean malformedHeaderStartsBody) {
/*  53*/        this.strictParsing = strictParsing;
/*  54*/        this.countLineNumbers = countLineNumbers;
/*  55*/        this.malformedHeaderStartsBody = malformedHeaderStartsBody;
/*  56*/        this.maxLineLen = maxLineLen;
/*  57*/        this.maxHeaderCount = maxHeaderCount;
/*  58*/        this.maxHeaderLen = maxHeaderLen;
/*  59*/        this.maxContentLen = maxContentLen;
/*  60*/        this.headlessParsing = headlessParsing;
        }

Upvotes: 0

Views: 1896

Answers (2)

Ahmed Abbas
Ahmed Abbas

Reputation: 1

The solution is to use the : apache-mime4j-core-0.7.2.jar and apache-mime4j-dom-0.7.2.jar

download the two jars and put them in : james-server-app-3.0.0-beta5-SNAPSHOT\lib.

You can download james-server-app-3.0.0-beta5 from : https://repository.apache.org/content/repositories/snapshots/org/apache/james/james-server-app/3.0.0-beta5-SNAPSHOT/.

Upvotes: 0

Mahesh
Mahesh

Reputation: 1

I got the same error and was searching for an answer. The error is because MimeConfig doesn't have a default constructor. I could get the mail successfully delivered locally by doing to following.

  1. Dowloaded apache-mime4j-core-0.8.0-20150617.024907-738-sources
  2. Created a default public constructor for MimeConfig
  3. Initialized all the variables with values shown in the static class Builder constructor
  4. Added setters for all the variables (Because I was getting NoSuchMethodError for setMaxLineLen)
  5. Created a jar called apache-mime4j-0.8.0-fix.jar and pushed into the lib folder
  6. I use run.sh, so replaced the mime4j core jar name with the above one.

I am sure there is some mismatch between spooler and mime4j. I think the calling code should use the Builder instead of directly trying to instantiate the MimeConfig.

Try these and let me know if it works. It worked for me. I am not sure if this is a permanent fix, but I can go ahead with exploring the V3 features till we get a permanent solution.

Upvotes: 0

Related Questions