Andrey Myatlyuk wrote:
> Hello Bo,
>
> Thursday, March 15, 2001, 1:31:56 PM, you wrote:
>
> BX> Andrey Myatlyuk wrote:
> [...]
Hi :-) I did a test with a very simplified MyHelper class,
* with jakarta-tomcat-3.2.1(standalone, JDK1.3, winnt40)
I put MyHelper.jar in:
- CLASSPATH
works. MyHelper is loaded by System classloader
- TOMCAT_HOME/lib
works. MyHelper is Also loaded by System classloader
- WEB-INF/lib
doesn't work. MyHelper is loaded by myapp(this webapp)
classloader, and after reloading, this classloader is "not there",
so/and I get a java.lang.CalssCastException.
* with jakarta-tomcat-4.0-b1(standalone, JDK1.3, winnt40)
I put MyHelper.jar in:
- CLASSPATH
works. MyHelper is loaded by System classloader
- TOMCAT_HOME/lib
works. MyHelper is loaded by another classloader, I guess
it is "Shared classloader"
- WEB-INF/lib
doesn't work. MyHelper is loaded by myapp(this webapp)
classloader, and after reloading, this classloader is "not there",
so/and I get a java.lang.CalssCastException.
* the following is simple testing code:
- MyServlet:
public void service(...) throws ...
if(req.getParameter("setget")!=null && req.getParameter("setget").equals("set")){
try{
arHelper arh0=new arHelper("hahahahaha");
System.out.println( "arh0.hashCode()="+arh0.hashCode() );
System.out.println(
"arh0.getClass().hashCode()="+arh0.getClass().hashCode() );
System.out.println(
"arh0.getClass().getClassLoader().hashCode()="+arh0.getClass().getClassLoader().hashCode()
);
System.out.println("\n");
this.getServletContext().setAttribute("name", arh0);
}catch(Exception e){System.out.println("in arh0, e="+e);}
}
if(req.getParameter("setget")!=null && req.getParameter("setget").equals("get")){
Object o= this.getServletContext().getAttribute("name");
try{
arHelper arh1=(arHelper)o;
System.out.println("arh1.s="+arh1.s);
System.out.println( "arh1.hashCode()="+arh1.hashCode() );
System.out.println(
"arh1.getClass().hashCode()="+arh1.getClass().hashCode() );
System.out.println(
"arh1.getClass().getClassLoader().hashCode()="+arh1.getClass().getClassLoader().hashCode()
);
System.out.println("\n");
}catch(Exception e){System.out.println("in arh1, e="+e);}
}
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.println("<html><body>");
out.println("in service, ok");
out.println("</body></html>");
out.close();
}
- MyHelper
public class arHelper{
public String s;
public arHelper(String s){
this.s = s;
}
}
Bo
Mar.15, 2001