Luckily, I found a solution from someone trying to use
GWT in an Openfire Plugin.
First, set a PluginClassLoader on your Plugin class. Here is my trimmed example:
...
private PluginClassLoader pluginClassLoader = null;
...
public void initializePlugin(PluginManager pManager, File pluginDirectory) {
pluginClassLoader = pManager.getPluginClassloader(this);
}
...
public PluginClassLoader getPluginClassLoader() {
return pluginClassLoader;
}
Then, in my class that attempts to load a Context, before loading it I do this:
MyPlugin myPlugin = (MyPlugin) XMPPServer.getInstance()
.getPluginManager().getPlugin("myplugin");
if (myPlugin != null && myPlugin.getPluginClassLoader() != null) {
Thread.currentThread().setContextClassLoader(
myPlugin.getPluginClassLoader().getClassLoader());
}
No comments:
Post a Comment