Hi,

I have read all the threads on servlets dynamically loading classes.
I have updated to Orion 1.3.8 and then 1.4.0. The servlet runs fine,
except for the class loading. I understand the issues that Ted Neward
explains (quite well) in his paper Understanding Class.forName, and
have tried (as you can see in the code) every combination of ClassLoader.

Note that I am able to dynamically load the servlet class, any of the
classes that the servlet references, and all are under the same tree,
which is under WEB-INF/classes. It is as if the servlet engine is
deciding that since the class I want (cmdClassName) is not directly
referenced by the servlet, it will not be loaded.

The classes are under <myapp>/myapp-web/WEB-INF/classes. I have verified
that the class file is where is belongs. The class file is dynamicaly
loadable by Tomcat. In fact, I had the class dynamically loading before
and simply can not remember what has changed and suspect that the class
was loadable by one of the parent loaders, and now that I have done an
upgrade I have cleaned out that class.

The debugging output is as follows:

>>  11/10/00 10:34 PM secdis-web: CMDCLAS 'sbd.sd.servlet.cmd.VerifyLogin'
>>  11/10/00 10:34 PM secdis-web: SYST_CL: sun.misc.Launcher$AppClassLoader@404536 - 
>CLASS = null
>>  11/10/00 10:34 PM secdis-web: THIS_CL: [ClassLoader: 
>[[C:\src\sd\build\sd\secdis-web\WEB-INF\classes]]] - CLASS = null
>>  11/10/00 10:34 PM secdis-web: CTXT_CL: [ThreadContextLoader, current context: 
>[ClassLoader: [[C:\src\sd\build\sd\secdis-web\WEB-INF\classes]]]] - CLASS = null
>>  11/10/00 10:34 PM secdis-web: sbd.sd.servlet.SDServlet: class 
>sbd.sd.servlet.SDServlet
>>  11/10/00 10:34 PM secdis-web: sbd.sd.servlet.cmd.SDServletCmd: class 
>sbd.sd.servlet.cmd.SDServletCmd
>>  11/10/00 10:34 PM secdis-web: COMMAND CLASS NOT FOUND: 
>'sbd.sd.servlet.cmd.VerifyLogin', sbd.sd.servlet.cmd.VerifyLogin

The file <myapp>/myapp-web/WEB-INF/classes/sbd/sd/servlet/cmd/VerifyLogin.class exists 
and is readble.

The (servlet) code that generates the above output is:

   ClassLoader cl = null;
   Class cmdClass = null;
   String cmdClassName = "sbd.sd.servlet.cmd.VerifyLogin";
   
   cl = ClassLoader.getSystemClassLoader();
   try {
      cmdClass = Class.forName( cmdClassName, true, cl );
      }
      catch ( ClassNotFoundException ex ) {}
   this.log( "SYST_CL: " + cl + " - CLASS = " + cmdClass );
   
   cl = this.getClass().getClassLoader();
   try {
      cmdClass = Class.forName( cmdClassName, true, cl );
      }
      catch ( ClassNotFoundException ex ) {}
   this.log( "THIS_CL: " + cl + " - CLASS = " + cmdClass );
   
   cl = Thread.currentThread().getContextClassLoader();
   try {
      cmdClass = Class.forName( cmdClassName, true, cl );
      }
      catch ( ClassNotFoundException ex ) {}
   this.log( "CTXT_CL: " + cl + " - CLASS = " + cmdClass );
   
   cl = Thread.currentThread().getContextClassLoader();
   try {
      cmdClass = Class.forName( "sbd.sd.servlet.SDServlet", true, cl );
      }
      catch ( ClassNotFoundException ex ) {}
   this.log( "sbd.sd.servlet.SDServlet: " + cmdClass );
   try {
      cmdClass = Class.forName( "sbd.sd.servlet.cmd.SDServletCmd", true, cl );
      }
      catch ( ClassNotFoundException ex ) {}
   this.log( "sbd.sd.servlet.cmd.SDServletCmd: " + cmdClass );


I am simply stumped. The classloaders look perfect. They point to the directory
the class is under! I can not see why this would be failing.

TIA,
tim.


Reply via email to