On Thu, Nov 26, 2009 at 9:25 AM, Martin Pepin <[email protected]> wrote:
> Hi,
>
> I think I am facing some kind of bug or limitation in the Openfire plugin
> environment that I can't figure out the root cause. In this piece of JAVA
> code of the sipx-openfire presence plug-in I query the Openfire plug-in
> manager to get the "kraken" plug-in instance, then cast it to the proper
> type. This is identical to what's being done by the kraken web component
> interfacing its own kraken plugin but in my case I do it from another
> Openfire plug-in. I get a cast error although the class type is identical in
> the exception text and in the class instance as well.
It is not identical. You have to consider both the classloader and the
class when comparing classes to each other. Note that a plugin is
loaded using its own classloader. Check your code to see what
classloader is being used to load the class and what classloader is
being used to compare the class.
Ranga
>
> Note: The "plugin-kraken.jar" file which contains the class definition for
> KrakenPlugin is located under
> /opt/openfire/plugins/kraken/lib/plugin-kraken.jar. I had to copy this jar
> file under /opt/openfire/plugins/sipx-openfire/lib/plugin-kraken.jar to have
> the sipx-openfire presence plugin resolve its symbol for the KrakenPlugin
> class. I could not simply have moved plugin-kraken.jar to a single location
> under /opt/openfire/lib because the kraken plugin would not load at all. It
> seems like the symbols dynamically loaded under
> /opt/openfire/plugins/kraken/lib plugin environment are not visible under
> the /opt/openfire/plugins/sipx-openfire/lib plugin environment.
>
> Here is the code that generates the exception:
> ==============================================
>
> import net.sf.kraken.KrakenPlugin;
> import org.jivesoftware.openfire.XMPPServer;
> import org.jivesoftware.openfire.container.Plugin;
> import org.jivesoftware.openfire.container.PluginManager;
>
> public XmppAccountInfo() {
> PluginManager pluginManager =
> XMPPServer.getInstance().getPluginManager();
> Plugin plugin;
> KrakenPlugin krakenPlugin;
>
> try {
> System.err.println("PluginMgr: " +
> pluginManager.toString());
> Collection<Plugin> collPg = pluginManager.getPlugins();
> for (Plugin pg : collPg) {
> System.err.println("PluginItem: " + pg.toString());
> }
> plugin = pluginManager.getPlugin("kraken");
> System.err.println("getPlugin returns string: " +
> plugin.toString());
> System.err.println("getPlugin returns getClass: " +
> plugin.getClass().getName() );
> krakenPlugin = (KrakenPlugin)plugin;
> } catch (Exception ex) {
> System.err.println("Cannot initialize the kraken plugin instance
> details follow:");
> System.err.println(ex);
> }
> }
>
> Here is the debug output from the code above:
> =============================================
> -bash-3.2$ cat openfire/stderror.log
> PluginMgr: org.jivesoftware.openfire.container.pluginmana...@1ad9b0f
> PluginItem: org.jivesoftware.openfire.container.adminconsoleplu...@42f352
> PluginItem:
> org.sipfoundry.openfire.plugin.presence.sipxopenfireplu...@b398da
> PluginItem: org.jivesoftware.openfire.plugin.searchplu...@7bbfb8
> PluginItem: net.sf.kraken.krakenplu...@1a93f38
> getPlugin returns string: net.sf.kraken.krakenplu...@1a93f38
> getPlugin returns getClass: net.sf.kraken.KrakenPlugin
> Cannot initialize the kraken plugin instance details follow:
> java.lang.ClassCastException: net.sf.kraken.KrakenPlugin cannot be cast to
> net.sf.kraken.KrakenPlugin
>
> _______________________________________________
> sipx-dev mailing list [email protected]
> List Archive: http://list.sipfoundry.org/archive/sipx-dev
> Unsubscribe: http://list.sipfoundry.org/mailman/listinfo/sipx-dev
> sipXecs IP PBX -- http://www.sipfoundry.org/
>
--
M. Ranganathan
_______________________________________________
sipx-dev mailing list [email protected]
List Archive: http://list.sipfoundry.org/archive/sipx-dev
Unsubscribe: http://list.sipfoundry.org/mailman/listinfo/sipx-dev
sipXecs IP PBX -- http://www.sipfoundry.org/