Subj : Re: Dynamically Loading Host Objects To : Eric Merritt From : Igor Bukanov Date : Tue Aug 26 2003 06:40 pm Eric Merritt wrote: > Hello all, > > I am attempting to dynamically load host objects on the fly and make > them available to the scope I am working with. Basically, I poll a > directory containing jar files for changes. When I find a change I > instantiate a URLClassloader and define any 'scriptable' classes. Then > I pass the class to the scope via the ScriptableObject.defineClass > function. This all works fine and everything, however, when any > scripts attempts to use classes defined this way it blows up with a > 'NoClassDefFoundError' error showing that it could not find the class > previously loaded into it. > > Have any of you done anything similar here? Is there a way to work > around this problem? I would hate to have to force an application > restart just to reload a changed host object. Try to remove org.mozilla.javascript.optimizer.InvokerImpl class for your Rhino jar. The class generates a special proxy classes to speedup invocation of functions defined by ScriptableObject.defineClass by avoiding using Java reflection for method calls. But it may have problems with loading of classes. Regards, Igor .