Bill,
It is not that JRun is caching your packaged classes, it's that JRun only
dynamically reloads classes in the servlet directory. JRun uses a special
class loader rather than the normal class loader. This special class loader
will re-load any class that has been modified in the servlet directory. It
only monitors these files, though.
I think their thinking was that if you change a servlet, you can reload it
at anytime and just re-run the init method. However, reloading non-servlet
classes dynamically would cause conflicts if there any existing instances of
the non-servlet object in memory. Consider if you had a Customer object in
memory, and then you changed the Customer class and JRun did reload it. It
would have to throw a ClassCastException because the old in-memory instances
of Customer are not the same class anymore as the class definition that was
just freshly loaded. This is, in fact, what happens if you keep non-servlet
classes in the servlet directory (I know from experience).
Since you packaged classes are in a subfolder of the servlet directory, or
elsewhere in the classpath, JRun does not monitor and dynamically reload
those. The only way to get those classes in the VM is to restart JRun so
that the VM is also restarted.
Brian J. Sayatovic
------------------------------
Date: Thu, 3 Aug 2000 12:03:39 -0400
From: "Shelton, William D" <[EMAIL PROTECTED]>
To: "JRun List (E-mail) (E-mail)" <[EMAIL PROTECTED]>
Subject: Object Caching Problem
Message-ID:
<[EMAIL PROTECTED]>
Hi List:
I'm new to JRun and somewhat new to Java, so please bear with me.
Symptom:
When I make changes to a class in a package, those changes are not reflected
in the calling servlet or JSP page UNLESS I restart the JRun Server. In
fact, I get a java.lang.NoSuchMethodError
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* Simplified Package Code: */
package mystuff;
public class
son{
protected String firstName = null;
Person(){}
public void setFirstName( String fName ){
this.firstName = fName;
}
public String getFirstName(){ return this.firstName; }
} //end
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The above simple code works fine when I call it from a servlet or JSP page
like so:
import mystuff.*;
import other.packages.*;
// snip ...
Person p = new Person();
p.setFirstName( "James" );
out.println( p.getFirstName() );
...
However, if I update this class to ALSO include:
protected String lastName = null;
public void setLastName( String lName ){
this.lastName = lName;
}
public String getLastName(){ return this.lastName }
...
Then when I invoke the servlet/JSP using :
Person p = new Person();
p.setFirstName( "James" );
p.setLastName ( "Kirk" );
out.println( p.getFirstName() + " " );
out.println( p.getLastName() );
...
the servlet throws a java.lang.NoSuchMethodError ...
If I restart the server, it works fine. It seems like JRun is caching the
classes in the package or is not refreshing the package.
Am I missing something obvious? Or is this a problem with a workaround?
Thanks in advance!
Bill
------------------------------------------------------------------------------
Archives: http://www.egroups.com/group/jrun-interest/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/jrun_talk
or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the
body.