Page 1 of 1

Reload java extensions

Posted: 30 Nov 2008, 17:32
by radz
I'm having a problem reloading java extensions without restarting the server. I have AutoReloadExtensions set to true and the console shows a message that extension has been reloaded, but it uses a cached version of the old class file. Same if I reload from the admin. If I restart the server, the new class is loaded without problem.

I using version 1.6.2.

Posted: 30 Nov 2008, 17:34
by radz
Sorry, meant to post this in the "Server Side Extension Development" section..

Posted: 02 Dec 2008, 07:42
by Lapo
Remove the "javaExtensions/" folder from the classpath. It will do the trick

Posted: 02 Dec 2008, 08:09
by radz
Worked perfect, thanks!

Posted: 26 Jul 2009, 14:51
by mhdside
I want to know :

- is there any downsides for removing the ./javaExtensions/; from the classpath?

- if the answer is no, why does it already exists in the classpath and why is it causing the problem of having to restart the server to update java extension...

Posted: 27 Jul 2009, 07:47
by Lapo
- is there any downsides for removing the ./javaExtensions/; from the classpath?

Not particularly.
By doing so you can enable runtime Java Extension reloading

- if the answer is no, why does it already exists in the classpath and why is it causing the problem of having to restart the server to update java extension...

This requires that you understand how class loaders work in Java.
With javaExtensions/ in the classpath your Extension classes will be loaded by the System ClassLoader, so you won't be able to reload them at runtime.

If javaExtensions/ is NOT in the classpath each Extension will be loaded in its own ClassLoader and dynamic reloading becomes possible

Posted: 27 Jul 2009, 08:00
by mhdside
interesting, although I`m not going deep into java, not to ClassLoaders but thanks for clearing how it works. thanks Lapo!

reloading child classes

Posted: 01 May 2010, 16:11
by stix
So this works for loading extensions specified in the config.xml. But what if there is only one "extension" class that instantiates other classes loaded from other java files.

Like:

public void handleInternalEvent(InternalEventObject ieo)
{
if (ieo.getEventName().equals("loginRequest"))
{
myCustomLogin login = new myCustomLogin(this);
login.loginUser(ieo);
}
}


In this case, only the parent extension gets reloaded, not all the other classes. Is there a way in Java to clear the heap memory without rebooting the server?

Posted: 01 May 2010, 16:26
by Lapo
No, all classes are reloaded, not just the main extension class.