Hi Albretch,

Java has classloaders inside it, and they "remember" the class. Once they have got the class, they dont reload it again... its cached in the class loader.
The class, not the instance.
The only way to reload a fresh class is to create another classloader.

So thats what you going to have to learn to do first.
Its a long story all on its own... and doesnt really have much to do with tomcat, other than tomcat does similar things internally, but you have no control over that. If your reloader works outside TC, it will work inside TC as well. ie you dont have to worry about TC's classloaders.
It means you can test your reloader in a normal little java app first.

Then if you are going to get into stuff like this, I suggest you learn servlets. They much easier when there is lots of code.

You are thinking NEW loads the class, in java, thats just the instance.
The class is loaded the second that JSP (servlet) is loaded and java see's the import for that class. So the import is not like a struct in C... it does more stuff behind the scenes.

If you want to late bind then you can use
Class.forName()
so the class can be late loaded... but I'm almost certain that once loaded, it will not see a change in the class... You have to build a custom classloader for that, but for what you doing its not too serious, the standard functionality is there, look up the "load" function.
And just remember to give it the parent class loader.

Better still google for Java Class reloading and classloaders, you bound to find the code, and you'll see its a fairly tricky area.

What you doing is not going to work :(

Good luck...


----- Original Message ----- From: "Albretch Mueller" <[EMAIL PROTECTED]>
To: <users@tomcat.apache.org>
Sent: Friday, May 23, 2008 2:46 PM
Subject: The type <. . .> is not visible


Hi

I need to check if the tc classloaders are able to load/reload generic classes.

So I created two sample classes in /webapps/ROOT/WEB-INF/classes/test/k00:

package test.k00;

class K00{
public int i0;
public long l0;
}

and

package test.k00;

import java.util.*;

// __
class GenK00{
private String aS;
public ArrayList<K00> ALK00;
// __
GenK00(String aS){
 this.aS = aS;
 ALK00 = new ArrayList<K00>();
}
}

which as you can see are in package test.k00

Then I simply rearrange the welcome-file-list so that index.jsp is
loaded first and included some test code right before theline "If
you're seeing this page ..."

         <p>
Loading Generic classes:<br/>
<[EMAIL PROTECTED] import="test.k00.*"%>
<%
K00 k0 = new K00();
k0.i0 = 0;
k0.l0 = 0L;
%>
         </p>

However I am getting "The type" K00 "is not visible" kinds of errors

How can I fix this error and make tc load the classes?

Once the classes are loaded, would tc reload them if K00 is changed to, say:

class K00{
public int i0;
public String aS0;
}

after you recompile it, or if a new class is dropped in this
directory, would tc load it?

Thanks
lbrtchx
---------------------------------------------------------------------------
HARBOR: http://coolharbor.100free.com/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
---------------------------------------------------------------------------

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