Index: pom.xml
===================================================================
--- pom.xml	(revision 945694)
+++ pom.xml	(working copy)
@@ -52,7 +52,7 @@
           <includeConfigurationDirectoryInClasspath>true</includeConfigurationDirectoryInClasspath>
           <environmentSetupFileName>setenv</environmentSetupFileName>
           <!--  set some sane defaults for memory -->
-          <extraJvmArguments>-Xms128m -Xmx512m</extraJvmArguments>
+          <extraJvmArguments>-Xms128m -Xmx512m -Djava.system.class.loader=org.apache.james.container.spring.JamesClassLoader</extraJvmArguments>
           <!-- Generate bin scripts for windows and unix per default -->
           <platforms>
             <platform>windows</platform>
@@ -132,6 +132,10 @@
                       <name>wrapper.java.maxmemory</name>
                       <value>512</value>
                     </property>
+                    <property>
+                      <name>wrapper.java.additional.1</name>
+                      <value>-Djava.system.class.loader=org.apache.james.container.spring.JamesClassLoader</value>
+                    </property>
                   </configuration>
                 </generatorConfiguration>
               </generatorConfigurations>
Index: src/main/java/org/apache/james/container/spring/JamesResourceLoader.java
===================================================================
--- src/main/java/org/apache/james/container/spring/JamesResourceLoader.java	(revision 945694)
+++ src/main/java/org/apache/james/container/spring/JamesResourceLoader.java	(working copy)
@@ -56,4 +56,13 @@
      * @return rootDir
      */
     public String getRootDirectory();
+
+    /**
+     * Return the directory where the external jar libraries must be placed by the
+     * administrator. The jars may contain mailets, jdbc drivers,...
+     * 
+     * @return externalLibraryDirectory
+     */
+    public String getExternalLibraryDirectory();
+    
 }
Index: src/main/java/org/apache/james/container/spring/JamesClassLoader.java
===================================================================
--- src/main/java/org/apache/james/container/spring/JamesClassLoader.java	(revision 0)
+++ src/main/java/org/apache/james/container/spring/JamesClassLoader.java	(revision 0)
@@ -0,0 +1,65 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.container.spring;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+/**
+ * The JamesClassLoader uses the provided system classloader
+ * and adds all jars found in the externla library directory.
+ * 
+ * Use "-Djava.system.class.loader=org.apache.james.container.spring.JamesClassLoader"
+ * when launching james for this class loader to be invoked.
+ */
+public class JamesClassLoader extends URLClassLoader {
+
+    /**
+     * The ClassLoader that will be used by James application.
+     * 
+     * The class is loaded using the default system class loader 
+     * defines this constructor with a single parameter is used as 
+     * the delegation parent.
+     * 
+     * @param classLoader
+     */
+    public JamesClassLoader(ClassLoader classLoader) {
+        super(new URL[0], classLoader);
+        String[] jars = new File(JamesServerApplicationContext.getResourceLoader().getExternalLibraryDirectory()).list(new FilenameFilter() {
+            public boolean accept(File dir, String name) {
+                return name.endsWith(".jar");
+            }
+        });
+        if (jars != null) {
+            for (int i=0; i < jars.length; i++) {
+                File file = new File(JamesServerApplicationContext.getResourceLoader().getExternalLibraryDirectory() + jars[i]);
+                try {
+                    super.addURL(file.toURI().toURL());
+                } catch (MalformedURLException e) {
+                	// At that time, we can not yet use non jvm classes for logging. Simply log on console. Should never come here...
+                	System.out.println("Got an unexpected exception while building the urls for the james class loader for file " + file.getAbsolutePath());
+                }
+            }
+        }
+    }
+
+}
Index: src/main/java/org/apache/james/container/spring/JamesServerWebApplicationContext.java
===================================================================
--- src/main/java/org/apache/james/container/spring/JamesServerWebApplicationContext.java	(revision 945694)
+++ src/main/java/org/apache/james/container/spring/JamesServerWebApplicationContext.java	(working copy)
@@ -82,11 +82,20 @@
             }
         }
 
+		public String getExternalLibraryDirectory() {
+            if (externalLibDirectory == null) {
+                return getRootDirectory() + "/WEB-INF/lib/";
+            } else {
+                return externalLibDirectory;
+            }
+		}
+
     };
     private String rootDirectory;
     private String absoluteDirectory;
     private String varDirectory;
     private String confDirectory;
+    private String externalLibDirectory;
 
     /*
      * (non-Javadoc)
@@ -120,6 +129,11 @@
     public void setConfDirectory(String confDirectory) {
         this.confDirectory = confDirectory;
     }
+    
+    public void setExternalLibDirectory(String externalLibDirectory) {
+        this.externalLibDirectory = externalLibDirectory;
+    }
+
     /*
      * (non-Javadoc)
      * @see org.apache.james.container.spring.JamesResourceLoader#getAbsoluteDirectory()
@@ -151,4 +165,12 @@
     public String getRootDirectory() {
         return resourceLoader.getRootDirectory();
     }
+
+	/* (non-Javadoc)
+	 * @see org.apache.james.container.spring.JamesResourceLoader#getExternalLibraryDirectory()
+	 */
+	public String getExternalLibraryDirectory() {
+		return getRootDirectory() + "/WEB-INF/lib/";
+	}
+	
 }
Index: src/main/java/org/apache/james/container/spring/JamesServerApplicationContext.java
===================================================================
--- src/main/java/org/apache/james/container/spring/JamesServerApplicationContext.java	(revision 945694)
+++ src/main/java/org/apache/james/container/spring/JamesServerApplicationContext.java	(working copy)
@@ -23,11 +23,11 @@
 import org.springframework.core.io.Resource;
 
 /**
- * {@link ApplicationContext} which loads all needed beans for JAMES
+ * {@link ApplicationContext} which loads all needed Spring beans for JAMES
  *
  */
 public class JamesServerApplicationContext extends ClassPathXmlApplicationContext implements JamesResourceLoader{
-
+	
     /**
      * The resourceloader to use. This must be defined as static, otherwise it will fail to startup..
      */
@@ -57,6 +57,13 @@
             return getRootDirectory() + "/var/";
         }
 
+        /* (non-Javadoc)
+         * @see org.apache.james.container.spring.JamesResourceLoader#getExternalLibraryDirectory()
+         */
+        public String getExternalLibraryDirectory() {
+            return getRootDirectory() + "/conf/lib/";
+        }
+
         /*
          * (non-Javadoc)
          * @see org.apache.james.container.spring.JamesResourceLoader#getRootDirectory()
@@ -64,10 +71,9 @@
         public String getRootDirectory() {
             return "../";
         }
-
+        
     };
     
-    
     public JamesServerApplicationContext(String[] configs) {
     	super(configs);
     }
@@ -116,5 +122,19 @@
     public String getRootDirectory() {
         return resourceLoader.getRootDirectory();
     }
+    
+	/* (non-Javadoc)
+	 * @see org.apache.james.container.spring.JamesResourceLoader#getExternalLibraryDirectory()
+	 */
+	public String getExternalLibraryDirectory() {
+        return resourceLoader.getExternalLibraryDirectory();
+	}
+
+    /**
+     * Protected accessor for the resource loader.
+     */
+    protected static JamesResourceLoader getResourceLoader() {
+    	return resourceLoader;
+    }
 
 }
