Restful api: cant get a user or all user sessions when a user already login

Version

  1. openfire 4.8.1
  2. restful api 1.10.2

problem

expected

get user or all user sessions

actual

<html>

<head>
    <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1" />
    <title>Error 500 Request failed.</title>
</head>

<body>
    <h2>HTTP ERROR 500 Request failed.</h2>
    <table>
        <tr>
            <th>URI:</th>
            <td>/plugins/restapi/v1/sessions/jack</td>
        </tr>
        <tr>
            <th>STATUS:</th>
            <td>500</td>
        </tr>
        <tr>
            <th>MESSAGE:</th>
            <td>Request failed.</td>
        </tr>
        <tr>
            <th>SERVLET:</th>
            <td>PluginServlet</td>
        </tr>
    </table>

</body>

</html>

openfire log

2024.06.20 11:06:01.950 TRACE [Jetty-QTP-AdminConsole-66]: org.jivesoftware.openfire.container.PluginServlet - Found servlet JerseyWrapper for path restapi/v1/sessions/jack
2024.06.20 11:06:01.950 TRACE [Jetty-QTP-AdminConsole-66]: org.jivesoftware.openfire.container.PluginServlet - Found servlet JerseyWrapper for path restapi/v1/sessions/jack
2024.06.20 11:06:01.950 TRACE [Jetty-QTP-AdminConsole-66]: org.jivesoftware.openfire.container.PluginServlet - Handling servlet at: /restapi/v1/sessions/jack
2024.06.20 11:06:01.953 ERROR [Jetty-QTP-AdminConsole-66]: org.jivesoftware.openfire.container.PluginServlet - org.glassfish.jersey.server.ContainerException: java.lang.NoSuchMethodError: 'int org.jivesoftware.openfire.session.ClientSession.getStatus()'
javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: java.lang.NoSuchMethodError: 'int org.jivesoftware.openfire.session.ClientSession.getStatus()'
    at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:410) ~[?:?]
    at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:346) ~[?:?]
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:358) ~[?:?]
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:311) ~[?:?]
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:205) ~[?:?]
    at org.jivesoftware.openfire.container.PluginServlet.handleServlet(PluginServlet.java:468) ~[xmppserver-4.8.1.jar:4.8.1]
    at org.jivesoftware.openfire.container.PluginServlet.service(PluginServlet.java:109) [xmppserver-4.8.1.jar:4.8.1]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:590) [jetty-servlet-api-4.0.6.jar:?]
    at org.eclipse.jetty.servlet.ServletHolder$NotAsync.service(ServletHolder.java:1419) [jetty-servlet-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:764) [jetty-servlet-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.servlet.ServletHandler$ChainEnd.doFilter(ServletHandler.java:1665) [jetty-servlet-10.0.18.jar:10.0.18]
    at org.jivesoftware.admin.PluginFilter.doFilter(PluginFilter.java:174) [xmppserver-4.8.1.jar:4.8.1]
    at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:202) [jetty-servlet-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1635) [jetty-servlet-10.0.18.jar:10.0.18]
    at org.jivesoftware.admin.AuthCheckFilter.doFilter(AuthCheckFilter.java:292) [xmppserver-4.8.1.jar:4.8.1]
    at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:202) [jetty-servlet-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1635) [jetty-servlet-10.0.18.jar:10.0.18]
    at com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129) [sitemesh-2.4.2.jar:?]
    at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77) [sitemesh-2.4.2.jar:?]
    at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:210) [jetty-servlet-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1635) [jetty-servlet-10.0.18.jar:10.0.18]
    at org.jivesoftware.admin.ContentSecurityPolicyFilter.doFilter(ContentSecurityPolicyFilter.java:53) [xmppserver-4.8.1.jar:4.8.1]
    at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:202) [jetty-servlet-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1635) [jetty-servlet-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:527) [jetty-servlet-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:131) [jetty-server-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:598) [jetty-security-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122) [jetty-server-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:223) [jetty-server-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1570) [jetty-server-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:221) [jetty-server-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1384) [jetty-server-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:176) [jetty-server-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:484) [jetty-servlet-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1543) [jetty-server-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:174) [jetty-server-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1306) [jetty-server-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:129) [jetty-server-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:149) [jetty-server-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:141) [jetty-server-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122) [jetty-server-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.server.Server.handle(Server.java:563) [jetty-server-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.server.HttpChannel$RequestDispatchable.dispatch(HttpChannel.java:1598) [jetty-server-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:753) [jetty-server-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:501) [jetty-server-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:287) [jetty-server-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:314) [jetty-io-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:100) [jetty-io-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.io.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:53) [jetty-io-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.runTask(AdaptiveExecutionStrategy.java:421) [jetty-util-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.consumeTask(AdaptiveExecutionStrategy.java:390) [jetty-util-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:277) [jetty-util-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.run(AdaptiveExecutionStrategy.java:199) [jetty-util-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:411) [jetty-util-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:969) [jetty-util-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1194) [jetty-util-10.0.18.jar:10.0.18]
    at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1149) [jetty-util-10.0.18.jar:10.0.18]
    at java.lang.Thread.run(Thread.java:829) [?:?]
Caused by: org.glassfish.jersey.server.ContainerException: java.lang.NoSuchMethodError: 'int org.jivesoftware.openfire.session.ClientSession.getStatus()'
    at org.glassfish.jersey.servlet.internal.ResponseWriter.rethrow(ResponseWriter.java:255) ~[?:?]
    at org.glassfish.jersey.servlet.internal.ResponseWriter.failure(ResponseWriter.java:237) ~[?:?]
    at org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:438) ~[?:?]
    at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:263) ~[?:?]
    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248) ~[?:?]
    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244) ~[?:?]
    at org.glassfish.jersey.internal.Errors.process(Errors.java:292) ~[?:?]
    at org.glassfish.jersey.internal.Errors.process(Errors.java:274) ~[?:?]
    at org.glassfish.jersey.internal.Errors.process(Errors.java:244) ~[?:?]
    at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265) ~[?:?]
    at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:234) ~[?:?]
    at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:684) ~[?:?]
    at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:394) ~[?:?]
    ... 57 more
Caused by: java.lang.NoSuchMethodError: 'int org.jivesoftware.openfire.session.ClientSession.getStatus()'
    at org.jivesoftware.openfire.plugin.rest.controller.SessionController.convertToSessionEntities(SessionController.java:133) ~[?:?]
    at org.jivesoftware.openfire.plugin.rest.controller.SessionController.getUserSessions(SessionController.java:68) ~[?:?]
    at org.jivesoftware.openfire.plugin.rest.service.SessionService.getUserSessions(SessionService.java:68) ~[?:?]
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
    at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
    at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52) ~[?:?]
    at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:134) ~[?:?]
    at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:177) ~[?:?]
    at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$TypeOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:219) ~[?:?]
    at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:81) ~[?:?]
    at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:475) ~[?:?]
    at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:397) ~[?:?]
    at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:81) ~[?:?]
    at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:255) ~[?:?]
    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248) ~[?:?]
    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244) ~[?:?]
    at org.glassfish.jersey.internal.Errors.process(Errors.java:292) ~[?:?]
    at org.glassfish.jersey.internal.Errors.process(Errors.java:274) ~[?:?]
    at org.glassfish.jersey.internal.Errors.process(Errors.java:244) ~[?:?]
    at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265) ~[?:?]
    at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:234) ~[?:?]
    at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:684) ~[?:?]
    at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:394) ~[?:?]
    ... 57 more

Summary

  1. call /plugins/restapi/v1/sessions fail when user already login
  2. how to fix this?

Sadly, this version of the REST API plugin is not compatible with Openfire 4.8.0 and later.

A fix for this is in the works: Fixed dependencies errors for Openfire 4.8.1 by Anckermann · Pull Request #194 · igniterealtime/openfire-restAPI-plugin · GitHub

Hopefully, this will soon resolve the problem.

1 Like

OK, i will take the way to fix and test my application and openfire.
thx~~

We’ve released version 1.11.0 of the REST API plugin, which should fix this problem! Read more about the release in https://discourse.igniterealtime.org/t/openfire-restapi-plugin-version-1-11-0-release