tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Veniamin Fichin <3ca28...@mail.ru>
Subject Re: shared/lib again...
Date Fri, 16 Apr 2004 06:37:49 GMT
Julio C├ęsar Aguilar wrote:

>>    If you use multiple instance Tomcat's feature, this may be the case. 
> 
> In Windows I'm using a single instance of tomcat, there's no 
> CATALINA_BASE so it should be the same as CATALINA_HOME if I understand 
> correctly.

    Then I don't know... My installation is that:

Win2K
Java is 1.4.1_01
CATALINA_HOME=D:\Tomcat-5.0.16
CATALINA_BASE=D:\Projects\CA (or any other)

    %CATALINA_BASE%\shared\lib contains jars needed by most 
applications, and that classes are visible to application. Removing 
CATALINA_BASE variable and placing jars into %CATALINA_HOME%\shared\lib 
still works.
    I just wrote a simple servlet that looks for the class whose name is 
passed as parameter.

<IsThereThisClass.java>
package org.unchqua.test.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class IsThereThisClass extends HttpServlet {

     public void doGet (HttpServletRequest req, HttpServletResponse resp)
                 throws ServletException, IOException {
         resp.setContentType("text/plain");
         PrintWriter out=resp.getWriter();
         String cn=req.getParameter("cn");
         ClassLoader cnLoader=null;
         if (cn==null) {
             out.println("No class name given, I want \"cn\" parameter");
             return;
         }
         out.print("The class \""+cn+"\" is");
         try {
             cnLoader=this.getClass().getClassLoader().loadClass(cn)
               .getClassLoader();
         }
         catch (ClassNotFoundException cnfe) {
             out.print(" not");
         }
         out.println(" found");
         if (cnLoader!=null) {
             out.println("Loader:\n--\n"+cnLoader+"--");
         }
     }

}
</IsThereThisClass.java>

    Map it to any working application and call it like 
classfind?cn=com.example.your.package.YourClass to see if it is visible 
to any webapp's classloader.
    What exactly the moment when CNFE is thrown? You said that the 
applications is not even start due to CNFE, so that classes are needed 
during deployment or while normal application functioning?

> In Linux I'm using a single binary of tomcat and have the jar in 
> CATALINA_BASE/shared/lib.



---------------------------------------------------------------------
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