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/18 21:50:47 UTC

Mailet configuration problem

Hi - I am a new user trying to set up the James server on my system and
have ran into a snag....According to the configuration.html document, it
gives an example of how to set up a mailet with a match statement as
follows -

- &ltmailet match="UserIs=root & HostIsLocal" class="Forward">

I have tried to enter this statement as is, in the james.conf.xml file
just to test it out, as well as my own versions, such as-
(this is just a test example, I plan to create my own class to handle
these emails soon)

  <mailet match="RecipientIs=nwag@darkstar,nwag@localhost &
SubjectIs=NEWSLETTER" class="ToProcessor">
               <processor> transport </processor>
               <notice> NWAG newsletter intercepted </notice>
   </mailet>

When I start up the James server, I get the following sort of
error/stack walkback -


Scanning jars for new Blocks...
Reading configuration
Exception in configuration The entity name must immediately follow the
'&' in th
e entity reference.
org.xml.sax.SAXParseException: The entity name must immediately follow
the '&' i
n the entity reference.
        at
org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1067
)
        at
org.apache.xerces.framework.XMLDocumentScanner.reportFatalXMLError(XM
LDocumentScanner.java:626)
        at
org.apache.xerces.framework.XMLDocumentScanner.scanAttValue(XMLDocume
ntScanner.java:513)
        at
org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumen
tScanner.java:1825)
        at
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.disp
atch(XMLDocumentScanner.java:1238)
        at
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentS
canner.java:381)
        at
org.apache.xerces.framework.XMLParser.parse(XMLParser.java:952)
        at org.apache.avalon.loader.Populate.load(Populate.java:29)
        at
org.apache.avalon.loader.AvalonConfiguration.getAvalonConfiguration(A
valonConfiguration.java:97)
        at org.apache.avalon.loader.Main.main(Main.java:80)



Trying to remove the space following the '&' (as hinted at by this error
message) merely gives a different error message about the need for a
semicolon... I have tried to correct this in just about every way I can
guess at... I assume that this syntax is an extension to XML because
there is no reference, in my books on XML, to using boolean expressions
(that I could find) in this fashion... It appears that the Xerces XML
parser is getting hung up on the "&' symbol an interpreting it as a
reference?  I am working in the Windows environment, and downloaded the
March 15, 2001 version if that helps... Much appreciate any help that
can be offered, and I look forward to using and maybe contributing to
the James project...

    Marc...    marcc@easystreet.com



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


Mailet installation problems

Posted by Marc <ma...@easystreet.com>.
> 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


Re: Mailet configuration problem

Posted by Marc <ma...@easystreet.com>.
Serge - Sure - When I unzipped the James zip file, there is a doc subdirectory
with a file called configuration.html. Within this file there is a section
titled "The Mailet processor pipeline" with a subsection called "Matches" which
starts out with the following paragraph -

The Match interface defines how match class should work. Their work is to split
a Vector of recipients into two: the
          ones matching a specified condition and all others. Condition may or
may not be present. You can make one simple
          boolean operation merging two matches into one or you can write your
own class implementing the Match interface.
          Currently implemented match:


Following the table of matchers, there are the following examples -

Some examples:
          - &ltmailet match="RecipientIsLocal" class="LocalDelivery">

          - &ltmailet match="UserIs=root & HostIsLocal" class="Forward">

          - &ltmailet match="SenderIs=badBoy@myhost,badGirl@yourhost"
class="Null">


The second example was the one I  tried to implement... Incidently, none of
these will work since the parser fails on the &lt encoding reporting the same
error I was getting from my attempts.....

Guess this means I have to write my own matcher classes eh?


    Marc...



Serge Knystautas wrote:

> Can you point me to where this example is?  Boolean logic is not supported,
> so I need to chase down and remove this example.
>
> Serge Knystautas
> Loki Technologies
> http://www.lokitech.com/
> ----- Original Message -----
> From: "Marc" <ma...@easystreet.com>
> To: <ja...@jakarta.apache.org>
> Sent: Sunday, March 18, 2001 3:50 PM
> Subject: Mailet configuration problem
>
> > Hi - I am a new user trying to set up the James server on my system and
> > have ran into a snag....According to the configuration.html document, it
> > gives an example of how to set up a mailet with a match statement as
> > follows -
> >
> > - &ltmailet match="UserIs=root & HostIsLocal" class="Forward">
> >
> > I have tried to enter this statement as is, in the james.conf.xml file
> > just to test it out, as well as my own versions, such as-
> > (this is just a test example, I plan to create my own class to handle
> > these emails soon)
> >
> >   <mailet match="RecipientIs=nwag@darkstar,nwag@localhost &
> > SubjectIs=NEWSLETTER" class="ToProcessor">
> >                <processor> transport </processor>
> >                <notice> NWAG newsletter intercepted </notice>
> >    </mailet>
> >
> > When I start up the James server, I get the following sort of
> > error/stack walkback -
> >
> >
> > Scanning jars for new Blocks...
> > Reading configuration
> > Exception in configuration The entity name must immediately follow the
> > '&' in th
> > e entity reference.
> > org.xml.sax.SAXParseException: The entity name must immediately follow
> > the '&' i
> > n the entity reference.
> >         at
> > org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1067
> > )
> >         at
> > org.apache.xerces.framework.XMLDocumentScanner.reportFatalXMLError(XM
> > LDocumentScanner.java:626)
> >         at
> > org.apache.xerces.framework.XMLDocumentScanner.scanAttValue(XMLDocume
> > ntScanner.java:513)
> >         at
> > org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumen
> > tScanner.java:1825)
> >         at
> > org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.disp
> > atch(XMLDocumentScanner.java:1238)
> >         at
> > org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentS
> > canner.java:381)
> >         at
> > org.apache.xerces.framework.XMLParser.parse(XMLParser.java:952)
> >         at org.apache.avalon.loader.Populate.load(Populate.java:29)
> >         at
> > org.apache.avalon.loader.AvalonConfiguration.getAvalonConfiguration(A
> > valonConfiguration.java:97)
> >         at org.apache.avalon.loader.Main.main(Main.java:80)
> >
> >
> >
> > Trying to remove the space following the '&' (as hinted at by this error
> > message) merely gives a different error message about the need for a
> > semicolon... I have tried to correct this in just about every way I can
> > guess at... I assume that this syntax is an extension to XML because
> > there is no reference, in my books on XML, to using boolean expressions
> > (that I could find) in this fashion... It appears that the Xerces XML
> > parser is getting hung up on the "&' symbol an interpreting it as a
> > reference?  I am working in the Windows environment, and downloaded the
> > March 15, 2001 version if that helps... Much appreciate any help that
> > can be offered, and I look forward to using and maybe contributing to
> > the James project...
> >
> >     Marc...    marcc@easystreet.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: james-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: james-user-help@jakarta.apache.org


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


Re: Mailet configuration problem

Posted by Serge Knystautas <se...@lokitech.com>.
Can you point me to where this example is?  Boolean logic is not supported,
so I need to chase down and remove this example.

Serge Knystautas
Loki Technologies
http://www.lokitech.com/
----- Original Message -----
From: "Marc" <ma...@easystreet.com>
To: <ja...@jakarta.apache.org>
Sent: Sunday, March 18, 2001 3:50 PM
Subject: Mailet configuration problem


> Hi - I am a new user trying to set up the James server on my system and
> have ran into a snag....According to the configuration.html document, it
> gives an example of how to set up a mailet with a match statement as
> follows -
>
> - &ltmailet match="UserIs=root & HostIsLocal" class="Forward">
>
> I have tried to enter this statement as is, in the james.conf.xml file
> just to test it out, as well as my own versions, such as-
> (this is just a test example, I plan to create my own class to handle
> these emails soon)
>
>   <mailet match="RecipientIs=nwag@darkstar,nwag@localhost &
> SubjectIs=NEWSLETTER" class="ToProcessor">
>                <processor> transport </processor>
>                <notice> NWAG newsletter intercepted </notice>
>    </mailet>
>
> When I start up the James server, I get the following sort of
> error/stack walkback -
>
>
> Scanning jars for new Blocks...
> Reading configuration
> Exception in configuration The entity name must immediately follow the
> '&' in th
> e entity reference.
> org.xml.sax.SAXParseException: The entity name must immediately follow
> the '&' i
> n the entity reference.
>         at
> org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1067
> )
>         at
> org.apache.xerces.framework.XMLDocumentScanner.reportFatalXMLError(XM
> LDocumentScanner.java:626)
>         at
> org.apache.xerces.framework.XMLDocumentScanner.scanAttValue(XMLDocume
> ntScanner.java:513)
>         at
> org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumen
> tScanner.java:1825)
>         at
> org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.disp
> atch(XMLDocumentScanner.java:1238)
>         at
> org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentS
> canner.java:381)
>         at
> org.apache.xerces.framework.XMLParser.parse(XMLParser.java:952)
>         at org.apache.avalon.loader.Populate.load(Populate.java:29)
>         at
> org.apache.avalon.loader.AvalonConfiguration.getAvalonConfiguration(A
> valonConfiguration.java:97)
>         at org.apache.avalon.loader.Main.main(Main.java:80)
>
>
>
> Trying to remove the space following the '&' (as hinted at by this error
> message) merely gives a different error message about the need for a
> semicolon... I have tried to correct this in just about every way I can
> guess at... I assume that this syntax is an extension to XML because
> there is no reference, in my books on XML, to using boolean expressions
> (that I could find) in this fashion... It appears that the Xerces XML
> parser is getting hung up on the "&' symbol an interpreting it as a
> reference?  I am working in the Windows environment, and downloaded the
> March 15, 2001 version if that helps... Much appreciate any help that
> can be offered, and I look forward to using and maybe contributing to
> the James project...
>
>     Marc...    marcc@easystreet.com



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