You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-user@james.apache.org by Marc <ma...@easystreet.com> on 2001/03/19 03:15:21 UTC

Mailet installation problems

> Hello to this group again -

> Hmmm apparently I don't understand the development process for mailets!
> ;-( I tried to do what I thought would be the obvious process, but I
> cannot get the James server to load my new mailet matcher class... Here is
> what I have done so far -

First, I added the following code to the james.conf.xml file to declare my
new matcher - NwagNewsLetterMatcher
(I will worry about the real class to handle these emails later....)

 <!-- Match NWAG Newsletters and send to web server -->
              <mailet
match="NwagNewsLetterMatcher=nwag@marcchamberlin.com,nwag@darkstar,nwag@localhost"
class="ToProcessor">
              <processor> transport </processor>
              <notice> NWAG newsletter intercepted </notice>
 </mailet>

Next, I created my own class in a Default package and exported it as a jar
file. This is my class -

import org.apache.mailet.*;
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;

class NwagNewsLetterMatcher extends GenericMatcher {
 private Set recipients;
}

public void init() throws javax.mail.MessagingException
{
 StringTokenizer st = new StringTokenizer(getCondition(), ", \t", false);
 recipients = new HashSet();
 while (st.hasMoreTokens()) {
  recipients.add(new MailAddress(st.nextToken()));
 }
}

public java.util.Collection match(org.apache.mailet.Mail mail) throws
javax.mail.MessagingException {
 Collection matching = new Vector();
 MimeMessage mm = mail.getMessage();
 String subject = mm.getSubject();
 for (Iterator i = mail.getRecipients().iterator(); i.hasNext();) {
  MailAddress rec = (MailAddress) i.next();
  if (matchRecipient(rec)
   && (subject != null && subject.equals("NEWSLETTER"))) {
   matching.add(rec);
  }
 }
 return matching;
}

public boolean matchRecipient(MailAddress recipient) {
 return recipients.contains(recipient);
}



As you can see, I borrowed from the RecipientIs and SubjectIs classes in
order to effect a logical "and" match condition between a set of email
recepients and an email subject. Next, I modified the CLASSPATH as follows -

LOCAL_CLASSPATH=Loader.jar;../lib/AvalonAware.jar;../lib/xerces.jar;../lib/mail_1_2.jar;../lib/activation.jar;../lib/mailet.jar;../lib/myprojects.jar

I was very much surprised that I had to also add the mailet.jar file to the
class path as well, in order to resolve references from my classes to
classes contained within that jar! This makes me suspect that I don't fully
understand the development environment because surely this is working for
other developers...  Maybe some additional documentation is needed??? ;-)
Anywise, that has gotten me a bit further, but now I am getting the
following error/walkback...  Any ideas????


2001.03.18 05:36:49 720 Channel default opened
Main: Could not load matcher (NwagNewsLetterMatcher);
  nested exception is:
        java.lang.IllegalAccessException: NwagNewsLetterMatcher
org.apache.mailet.MailetException: Could not load matcher
(NwagNewsLetterMatcher
);
  nested exception is:
        java.lang.IllegalAccessException: NwagNewsLetterMatcher
        at
org.apache.james.transport.MatchLoader.getMatcher(MatchLoader.java:65
)
        at
org.apache.james.transport.JamesSpoolManager.init(JamesSpoolManager.j
ava:92)
        at org.apache.james.James.init(James.java:240)
        at org.apache.avalon.engine.Avalon.initBlock(Avalon.java:144)
        at org.apache.avalon.engine.Avalon.init(Avalon.java:112)
        at org.apache.avalon.loader.Main.main(Main.java:88)


Am I doing something really wrong? Again many thanks for all your patience
and help in getting me started with this James server.....

   Marc



---------------------------------------------------------------------
To unsubscribe, e-mail: james-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-user-help@jakarta.apache.org