Avatar Resizer Plugin Does Not Work - Critical Error!

Hello,

I was developing a new plugin and used Avatar Resizer (https://www.igniterealtime.org/projects/openfire/plugins/1.0.1/avatarResizer/readme.html) as my base source code since I was modifying vCards. I ran into an error in my code, and turns out the Avatar Resizer plugin has the same error as well. It appears the plugin does not work and I was hoping someone could help me understand why it is not working so that I can write a plugin.

In short, the plugin is overriding the org.jivesoftware.openfire.vcard.DefaultVCardProvider with a custom class org.igniterealtime.openfire.plugin.avatarresizer.DelegateVCardProvider. I am trying to accomplish the same by writing my own loadVCard function.

Any help would be greatly appreciated.

Error message:
2019.08.21 04:51:27 WARN [pool-58-thread-1]: org.jivesoftware.util.SystemProperty - Class org.igniterealtime.openfire.plugin.avatarresizer.DelegateVCardProvider was not found
java.lang.ClassNotFoundException: org.igniterealtime.openfire.plugin.avatarresizer.DelegateVCardProvider
at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[?:1.8.0_222]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_222]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_222]
at java.lang.Class.forName0(Native Method) ~[?:1.8.0_222]
at java.lang.Class.forName(Class.java:264) ~[?:1.8.0_222]
at org.jivesoftware.util.SystemProperty.lambda$static$9(SystemProperty.java:100) ~[xmppserver-4.4.1.jar:4.4.1]
at org.jivesoftware.util.SystemProperty.getValue(SystemProperty.java:302) [xmppserver-4.4.1.jar:4.4.1]
at org.jivesoftware.util.SystemProperty$1.propertySet(SystemProperty.java:195) [xmppserver-4.4.1.jar:4.4.1]
at org.jivesoftware.util.PropertyEventDispatcher.dispatchEvent(PropertyEventDispatcher.java:87) [xmppserver-4.4.1.jar:4.4.1]
at org.jivesoftware.util.JiveProperties.put(JiveProperties.java:302) [xmppserver-4.4.1.jar:4.4.1]
at org.jivesoftware.util.JiveGlobals.setProperty(JiveGlobals.java:811) [xmppserver-4.4.1.jar:4.4.1]
at org.jivesoftware.util.JiveGlobals.setProperty(JiveGlobals.java:793) [xmppserver-4.4.1.jar:4.4.1]
at org.igniterealtime.openfire.plugin.avatarresizer.AvatarResizerPlugin.initializePlugin(AvatarResizerPlugin.java:25) [avatarResizer-lib.jar!/:?]
at org.jivesoftware.openfire.container.PluginManager.loadPlugin(PluginManager.java:638) [xmppserver-4.4.1.jar:4.4.1]
at org.jivesoftware.openfire.container.PluginMonitor$MonitorTask$4.call(PluginMonitor.java:381) [xmppserver-4.4.1.jar:4.4.1]
at org.jivesoftware.openfire.container.PluginMonitor$MonitorTask$4.call(PluginMonitor.java:369) [xmppserver-4.4.1.jar:4.4.1]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_222]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_222]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_222]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]
2019.08.21 04:51:27 ERROR [pool-58-thread-1]: org.jivesoftware.openfire.container.PluginManager - An exception occurred while loading plugin ‘avatarresizer’:
java.lang.ClassCastException: org.jivesoftware.openfire.vcard.DefaultVCardProvider cannot be cast to org.igniterealtime.openfire.plugin.avatarresizer.DelegateVCardProvider
at org.igniterealtime.openfire.plugin.avatarresizer.AvatarResizerPlugin.initializePlugin(AvatarResizerPlugin.java:27) ~[avatarResizer-lib.jar!/:?]
at org.jivesoftware.openfire.container.PluginManager.loadPlugin(PluginManager.java:638) [xmppserver-4.4.1.jar:4.4.1]
at org.jivesoftware.openfire.container.PluginMonitor$MonitorTask$4.call(PluginMonitor.java:381) [xmppserver-4.4.1.jar:4.4.1]
at org.jivesoftware.openfire.container.PluginMonitor$MonitorTask$4.call(PluginMonitor.java:369) [xmppserver-4.4.1.jar:4.4.1]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_222]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_222]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_222]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]

Avatar Resizer was only required in older versions of Openfire.

Hello wroot,

Note that I do not need this plugin as I see the feature is now standard. What I am seeking is an example of how of a plugin to override a class function so I can write my own plugin. I want to override the loadVcard function with my own code.

As this plugin was designed to work with older Openfire code it is probably not the best candidate to build upon. Maybe @guus will have some advice.

Thanks wroot,

@guus any assistance you can provide would be great. Again, not looking to use Avatar Resizer code or implement a feature alike. I am looking to develop a plugin that successfully implements the VCardProvider class.

One of the reasons why avatarResizer got moved into the core was because of the issue that you’re experiencing.

A plugin that gets loaded in Openfire runs in its own classloader. When Openfire tries to load a class, it doesn’t consider these classloaders - making the class ‘invisible’ to it.

You can work around this issue by wrapping your code in a standard java library, and adding that to the ‘lib’ folder of Openfire. It’s not as flexible as a plugin, but it works just fine.

Helli @guus

Thank you for your reply. Can you provde a very basic code same which just shows how to overwite a function like loadVCard? Or, can you direct me to any other plugin that does this?

As I have not written a plugin of this sort, it would be greatly appreciated to have an example I can learn from.

Thanks.

Nothing pops to mind, sorry.

Thanks @guus,

If anyone has any class that they can share or provide an example of how to write a plugin that implements another class that would be greatly appreciated.

Hello @guus,

In reference to your suggestion, are you meaning to add the jar file to the /usr/share/openfire/lib folder? Also, would the code be similar to the below?

public class DelegateVCardProvider implements VCardProvider {

    public Element loadVCard(String username) {
       // code here....
        return element;
    }
}

Aside: I have often wondered about experimenting with getting the XMPPServer to expose it’s own class loader as a plugin class loader, allowing plugins the ability to add their own classes to “core” Openfire.

Greg

Hi guys,
I get this old topic up again, as I was searching with the same error having installed this plugin.

I am just wondering why this plugin is still listed, as the function is already built in in the newer versions of openfire. And no note on this in the plugin-readme either.

Will remove it then.