Mike

REST API Plugin: NullPointerException when setting MUC group affiliations

Discussion created by Mike on Aug 21, 2016
Latest reply on Aug 23, 2016 by Mike

When I add "mygroup" as admin to "myroom" in the Openfire Admin console and then execute a GET for http://[server:port]/plugins/restapi/v1/chatrooms/myroom/, I get the expected result:

 

<chatRoom>

   <roomName>myroom</roomName>

    ...

   <adminGroups>

      <adminGroup>mygroup</adminGroup>

   </adminGroups>

</chatRoom>

 

When I try to PUT the exact same payload though, the request fails:

 

HTTP/1.1 500 Server Error

Date: Sun, 21 Aug 2016 15:20:49 GMT

Set-Cookie: JSESSIONID=c4tf6lzq9xlc192lg5swb9e94;Path=/;HttpOnly

Expires: Thu, 01 Jan 1970 00:00:00 GMT

Content-Length: 0

 

The Openfire error log contains:

 

2016.08.21 17:20:49 ERROR [Jetty-QTP-AdminConsole-728]: org.jivesoftware.openfire.container.PluginServlet -

java.lang.NullPointerException

  at com.sun.xml.internal.bind.v2.runtime.reflect.Lister$CollectionLister.addToPack( Lister.java:289)

  at com.sun.xml.internal.bind.v2.runtime.reflect.Lister$CollectionLister.addToPack( Lister.java:253)

  at com.sun.xml.internal.bind.v2.runtime.unmarshaller.Scope.add(Scope.java:106)

  at com.sun.xml.internal.bind.v2.runtime.property.ArrayERProperty$ReceiverImpl.rece ive(ArrayERProperty.java:198)

  at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.endEleme nt(UnmarshallingContext.java:597)

  at com.sun.xml.internal.bind.v2.runtime.unmarshaller.SAXConnector.endElement(SAXCo nnector.java:165)

  at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Abstrac tSAXParser.java:609)

  at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndE lement(XMLDocumentFragmentScannerImpl.java:1776)

  at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$Fragment ContentDriver.next(XMLDocumentFragmentScannerImpl.java:2964)

  at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocument ScannerImpl.java:606)

  at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocu mentScannerImpl.java:118)

  at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocu ment(XMLDocumentFragmentScannerImpl.java:504)

  at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Config uration.java:848)

  at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Config uration.java:777)

  at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)

  at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXP arser.java:1213)

  at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXPa rserImpl.java:643)

  at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(U nmarshallerImpl.java:243)

  at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(Un marshallerImpl.java:214)

  at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerI mpl.java:140)

  at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerI mpl.java:123)

  at com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider.readFrom(XMLRoo tElementProvider.java:115)

  at com.sun.jersey.core.provider.jaxb.AbstractRootElementProvider.readFrom(Abstract RootElementProvider.java:111)

  at com.sun.jersey.spi.container.ContainerRequest.getEntity(ContainerRequest.java:4 90)

  at com.sun.jersey.server.impl.model.method.dispatch.EntityParamDispatchProvider$En tityInjectable.getValue(EntityParamDispatchProvider.java:123)

  at com.sun.jersey.server.impl.inject.InjectableValuesProvider.getInjectableValues( InjectableValuesProvider.java:86)

  at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatch Provider$EntityParamInInvoker.getParams(AbstractResourceMethodDispatchProvider.j ava:153)

  at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatch Provider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.jav a:203)

  at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.d ispatch(ResourceJavaMethodDispatcher.java:75)

  at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java: 302)

  at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule .java:147)

  at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule .java:108)

  at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule .java:147)

  at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourc eClassesRule.java:84)

  at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApp licationImpl.java:1542)

  at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApp licationImpl.java:1473)

  at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebAppl icationImpl.java:1419)

  at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebAppl icationImpl.java:1409)

  at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409 )

  at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer. java:540)

  at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer. java:715)

  at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)

  at org.jivesoftware.openfire.container.PluginServlet.handleServlet(PluginServlet.j ava:318)

  at org.jivesoftware.openfire.container.PluginServlet.service(PluginServlet.java:11 1)

  at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)

  at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812)

  at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.ja va:1669)

  at org.jivesoftware.admin.PluginFilter.doFilter(PluginFilter.java:80)

  at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.ja va:1652)

  at org.jivesoftware.admin.AuthCheckFilter.doFilter(AuthCheckFilter.java:162)

  at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.ja va:1652)

  at com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:11 8)

  at com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:52)

  at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.ja va:1652)

  at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)

  at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)

  at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)

  at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:22 3)

  at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:11 27)

  at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)

  at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185 )

  at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:106 1)

  at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)

  at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandler Collection.java:215)

  at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.jav a:110)

  at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)

  at org.eclipse.jetty.server.Server.handle(Server.java:499)

  at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)

  at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)

  at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)

  at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635 )

  at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)

  at java.lang.Thread.run(Thread.java:745)

 

When I empty the <adminGroups> element, the PUT requests succeeds.

 

Tested on Openfire 4.0.3.

Outcomes