tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alberto Romei" <a.ro...@centrosistemi.it>
Subject Re: Custom ClassLoader
Date Fri, 11 Apr 2003 13:33:05 GMT

the main goal of my ClassLoader is to read my webapp's classes from
encrypted class files.
I would like to deploy .class files that have been altered in some way, and
then decrypt  the contents of such .class files when they are read (by using
a custom implementation of ClassLoader).

I forgot to say that I use tomcat 4.0.6, but i need it working on 4.0.1,
too.

Thanks

Alberto.


----- Original Message -----
From: "Shapira, Yoav" <Yoav.Shapira@mpi.com>
To: "Tomcat Users List" <tomcat-user@jakarta.apache.org>
Sent: Friday, April 11, 2003 2:50 PM
Subject: RE: Custom ClassLoader



Howdy,
Oh, these are hot waters ;(  I don't feel like downloading and trying
your custom classloader implementation, so I don't have a straight
answer to your question.  But I do have a question for you: what are you
trying to do with your custom classloader?

Yoav Shapira
Millennium ChemInformatics


>-----Original Message-----
>From: Alberto Romei [mailto:a.romei@centrosistemi.it]
>Sent: Friday, April 11, 2003 7:23 AM
>To: tomcat-user@jakarta.apache.org
>Subject: Custom ClassLoader
>
>Hi, all !
>
>I need to tell tomcat to use a custom implementation of ClassLoader for
a
>specific context.
>
>The documentation explains the use of  <Loader
loaderClass="pkg.ClassName">
>inside the <Context> element, but I saw that the "loaderClass"
attribute is
>ignored (bug #12501).
>The only way I found is to create a subclass of WebappLoader and
specify it
>in <Loader className="prova.MyLoader">, tweaking the getClassLoader()
>method.
>Here is the code of my experiment :
>
>= = = = = = = = = =
>package prova;
>
>import java.io.*;
>import java.net.*;
>import org.apache.catalina.loader.WebappLoader;
>import org.apache.catalina.loader.WebappClassLoader;
>
>public class MyLoader extends WebappLoader
>{
>  static
>  {
>    System.out.println("*****************Here I
am*******************");
>  }
>
>  ClassLoader cl;
>  public MyLoader()
>  {
>    super();
>  }
>
>  public MyLoader(java.lang.ClassLoader parent)
>  {
>    super(parent);
>  }
>
>
>  public ClassLoader getClassLoader()
>  {
>    if (cl==null)
>    {
>      URLClassLoader push = (URLClassLoader)super.getClassLoader();
>      cl = new URLClassLoader(push.getURLs(), push)
>      {
>         public String toString()
>         {
>           String rv = "***** Prova *****\r\n";
>           URL arr[] = ((WebappClassLoader)this.getParent()).getURLs();
>           for (int i=0; i<arr.length; i++)
>             rv += arr[i]+"\r\n";
>           rv += "***** Prova *****\r\n";
>           rv += super.toString();
>           return rv;
>         }
>      };
>    }
>    return cl;
>  }
>}
>= = = = = = = = = =
>
>
>I placed the class under tomcat/common/classes and it is loaded
normally (i
>see "*****************Here I am*******************" in the output), but
>tomcat cannot compile JSPs any more. When I make a request to a jsp, I
get
>errors like:
>  Class javax.servlet.http.HttpServlet not found...
>  Package javax.servlet not found in import...
>
>It seems like the classloader has lost all the paths, even if I set the
>parent of my ClassLoader to the default WebappClassLoader.
>
>Any suggestion is appreciated...
>
>Thanks
>Alberto
>
>
>
>
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org




This e-mail, including any attachments, is a confidential business
communication, and may contain information that is confidential, proprietary
and/or privileged.  This e-mail is intended only for the individual(s) to
whom it is addressed, and may not be saved, copied, printed, disclosed or
used by anyone else.  If you are not the(an) intended recipient, please
immediately delete this e-mail from your computer system and notify the
sender.  Thank you.


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


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


Mime
View raw message