On 12/06/07, David Delbecq <[EMAIL PROTECTED]> wrote:
[..]
1) revise war build process to force inclusion of libs

2) have a server lifecyclelistener  that, before loading of a webapp,
copy the concerned classes to the WEB-INF/lib ?

Copy seems easier than play with classloader...

Here is my solution which I tested and it works pretty fine:
1/ in conf/context.xml I put:
   <Listener className="foo.FooListener" extDir="${catalina.home}/ext-lib/"/>

2/ I put my foo.FooListener in jar and then in ./server/lib/

3/ source code:

/** FIXME polish, add logging, exception handling, etc */
public class FooListener implements LifecycleListener {

 private String extDir;

 public String getExtDir() {
   return extDir;
 }

 public void lifecycleEvent(LifecycleEvent event) {
   if (Lifecycle.START_EVENT.equals(event.getType())) {
     if (event.getSource() != null) {
       final StandardContext ctx = (StandardContext) event.getSource();
       final File dir = new File(getExtDir());
       File[] files = dir.listFiles();
       for (int i = 0; i < files.length; i++) {
         ctx.getLoader().addRepository("file://" + files[i].getAbsolutePath());
       }
     }
   }
 }

 /**
  * Required configuration parameter.
  *
  * @param extDir
  */
 public void setExtDir(String extDir) {
   this.extDir = extDir;
 }

}

That's all, it works fine, it does not affect classloader hierarchy
and it is logically equal to copy-based solution.

Thanks for your help, now let's wait what customer say ;)

Hamster,

--
GMail::Hamster
http://music-codex.com/
http://hamsterready.blogspot.com/

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to