How do I deploy my custom mailets?

This information applies to James v2.2 and later -- instructions for older versions are at the bottom of the page.

You can place:

You can place classes upon which your classes depend here also.

You then have to configure James to look in those packages for your mailets:

For this example, ours are in tld.domain.james.transport.mailets (do not use this name in a real package).



Mailet Developers Please Note

The classloaders created inherit the same loader used by the spoolmanager, and hence have access to all the same classes in the same loader as James does. This allows mailets to access the underlying Avalon services via the mailet context. This breaks the intended design for the v3 mailet context, which should be unable to be used to get details of the context implementation.

However, this classloader seperation is not applicable to v2, so the changes conform to James & Mailet v2. But we would STRONGLY URGE mailet developers not to access the underlying Avalon services directly where at all possible (or make this code easily maintainable) because this access WILL be restricted in future versions for security reasons.

It is our stated intention that we will improve mailet deployment by supporting "mailet applications" which will run in an isolated classloader space, thereby preventing access from those mailets to James and other mailet applications running in the same James instance. Therefore in James v3 and Mailet v3 the only services available will be accessed via mechanisms explicitly provided by the mailet context.

Instructions for older versions

Community member IanH contributes the following:

(Minor corrections by Andrew Hayden 16 Apr 2004 @ 01:12)

If you are on 2.1.x, you need to

  1. unjar the James.sar file
  2. unjar the james.jar (or .bar for 2.0.x) file
  3. add your mailet's .class files into the james.jar (or .bar for 2.0.x) file
  4. rejar james.jar or .bar
  5. rejar james.sar

Here's the ant xml snippet which requires James 2.1.x (doesn't work for James 2.0.x) and Ant version that supports <jar ... update='true' />, assuming you've placed your compiled .class files (and the appropriate package directory structure) into a subdirectory called 'myCompiledMailet':

          |  src.sar.file = The james.sar (WATCH IT:  SAR FILE not JAR FILE)
          |                 from James 2.1.x
          |  update.sar.file = The orignal james.sar + your custom mailets .
       <property name="src.sar.file"               value="./james.sar" />
       <property name="updated.sar.file"           location="./customSAR/james.sar" />

          |  This is where ant will do its work
       <property name=''               location='./sarWorkDir'/>


          |  This is where your custom mailet classes should reside
          |  They will be merged into james.jar
       <property name='compiled.dir'               location='./myCompiledMailet' />

       <!-- here's where all the work is being done -->
       <target name="assemble" description="Assembling SAR + Adding Custom Mailet">

           <echo>removing and re-creating work directory [${}]</echo>
           <delete dir="${}" verbose="no" />
           <mkdir  dir="${}/" />

           <delete dir="./customSAR" verbose="no" />
           <mkdir  dir="./customSAR" />

           <!-- Unjar'ing the SAR file to get at the James.jar file -->

           <echo>Unjaring sar file [${src.sar.file}] to work directory [${}]</echo>
           <unjar src="${src.sar.file}" dest="${}" />

           <echo>Updating [${}/SAR-INF/lib/james.jar] by adding our custom mailet classes from [${compiled.dir}] </echo>
           <jar jarfile="${}/SAR-INF/lib/james.jar" basedir="${compiled.dir}" update="true" />

           <echo>Re-adding [${}/SAR-INF/lib/james.jar] into [${updated.sar.file}]</echo>

           <copy file="${src.sar.file}" todir="${dist}" />

           <jar jarfile="${updated.sar.file}" basedir="${}" update="true" />

CustomMailetPackages (last edited 2009-09-20 22:58:31 by localhost)