powered by Jive Software

RestAPI plugin unexpected problem attempting to register servlets

Openfire v4.6.3
RestAPI plugin v1.4.0

We see this stacktrace on server start/restart. The RestAPI plugin reports that it’s registered afterwards.

2021.04.25 19:10:32 DEBUG [pool-7-thread-2]: org.jivesoftware.openfire.container.PluginManager - Loading plugin 'restapi'...
2021.04.25 19:10:33 DEBUG [pool-7-thread-2]: org.jivesoftware.openfire.container.PluginServlet - Loading servlet 'JerseyWrapper' of plugin 'restapi'...
2021.04.25 19:10:33 DEBUG [pool-7-thread-2]: org.jivesoftware.openfire.container.PluginServlet - Initializing servlet 'JerseyWrapper' of plugin 'restapi'...
2021.04.25 19:10:33 ERROR [pool-7-thread-2]: org.jivesoftware.openfire.container.PluginServlet - An unexpected problem occurred while attempting to register servlets for plugin 'org.jivesoftware.openfire.plugin.rest.RESTServicePlugin@719960c8'.
java.lang.NoClassDefFoundError: javax/ws/rs/ext/MessageBodyReader
	at java.lang.ClassLoader.defineClass1(Native Method) ~[?:1.8.0_282]
	at java.lang.ClassLoader.defineClass(ClassLoader.java:756) ~[?:1.8.0_282]
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[?:1.8.0_282]
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:468) ~[?:1.8.0_282]
	at java.net.URLClassLoader.access$100(URLClassLoader.java:74) ~[?:1.8.0_282]
	at java.net.URLClassLoader$1.run(URLClassLoader.java:369) ~[?:1.8.0_282]
	at java.net.URLClassLoader$1.run(URLClassLoader.java:363) ~[?:1.8.0_282]
	at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_282]
	at java.net.URLClassLoader.findClass(URLClassLoader.java:362) ~[?:1.8.0_282]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418) ~[?:1.8.0_282]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[?:1.8.0_282]
	at java.lang.Class.forName0(Native Method) ~[?:1.8.0_282]
	at java.lang.Class.forName(Class.java:348) ~[?:1.8.0_282]
	at com.sun.jersey.core.reflection.ReflectionHelper$3.run(ReflectionHelper.java:284) ~[?:?]
	at com.sun.jersey.core.reflection.ReflectionHelper$3.run(ReflectionHelper.java:279) ~[?:?]
	at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_282]
	at com.sun.jersey.spi.service.ServiceFinder$AbstractLazyIterator.hasNext(ServiceFinder.java:697) ~[?:?]
	at com.sun.jersey.spi.service.ServiceFinder.toClassArray(ServiceFinder.java:549) ~[?:?]
	at com.sun.jersey.core.spi.component.ProviderServices.getServiceClasses(ProviderServices.java:345) ~[?:?]
	at com.sun.jersey.core.spi.component.ProviderServices.getServiceClasses(ProviderServices.java:338) ~[?:?]
	at com.sun.jersey.core.spi.component.ProviderServices.getServices(ProviderServices.java:162) ~[?:?]
	at com.sun.jersey.core.spi.factory.MessageBodyFactory.initReaders(MessageBodyFactory.java:176) ~[?:?]
	at com.sun.jersey.core.spi.factory.MessageBodyFactory.init(MessageBodyFactory.java:162) ~[?:?]
	at com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(WebApplicationImpl.java:1338) ~[?:?]
	at com.sun.jersey.server.impl.application.WebApplicationImpl.access$700(WebApplicationImpl.java:180) ~[?:?]
	at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:799) ~[?:?]
	at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:795) ~[?:?]
	at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193) ~[?:?]
	at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:795) ~[?:?]
	at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:790) ~[?:?]
	at com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:509) ~[?:?]
	at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:339) ~[?:?]
	at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:605) ~[?:?]
	at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:207) ~[?:?]
	at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:394) ~[?:?]
	at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:577) ~[?:?]
	at javax.servlet.GenericServlet.init(GenericServlet.java:244) ~[javax.servlet-api-3.1.0.jar:3.1.0]
	at org.jivesoftware.openfire.plugin.rest.service.JerseyWrapper.init(JerseyWrapper.java:159) ~[?:?]
	at org.jivesoftware.openfire.container.PluginServlet.registerServlets(PluginServlet.java:215) [xmppserver-4.6.3.jar:4.6.3]
	at org.jivesoftware.openfire.container.PluginManager.loadPlugin(PluginManager.java:667) [xmppserver-4.6.3.jar:4.6.3]
	at org.jivesoftware.openfire.container.PluginMonitor$MonitorTask$4.call(PluginMonitor.java:375) [xmppserver-4.6.3.jar:4.6.3]
	at org.jivesoftware.openfire.container.PluginMonitor$MonitorTask$4.call(PluginMonitor.java:363) [xmppserver-4.6.3.jar:4.6.3]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_282]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_282]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_282]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_282]
Caused by: java.lang.ClassNotFoundException: javax.ws.rs.ext.MessageBodyReader
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[?:1.8.0_282]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418) ~[?:1.8.0_282]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[?:1.8.0_282]
	... 46 more

I’m not able to reproduce this issue using Openfire v4.6.3 and the REST API plugin v1.4.0. I’ve tried starting the server, installing the plugin, and restarting the server. Later, I retried, but restarting the server only after some activity was performed on the REST API - but still, no luck.