powered by Jive Software

REST Plugin 500 exception

When I’m trying to create an user by the REST API I’m having this exception:

016.07.04 20:08:08 ERROR [Jetty-QTP-AdminConsole-35]: org.jivesoftware.openfire.container.PluginServlet -

java.lang.NullPointerException

at org.jivesoftware.openfire.plugin.UserServicePluginNG.createUser(UserServicePlug inNG.java:77)

at org.jivesoftware.openfire.plugin.service.UserService.createUser(UserService.jav a:38)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.ja va:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvoke rFactory.java:60)

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

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.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)

I’m using Openfire 4.0.2 and this is the request.

POST /plugins/userService/users/ HTTP/1.1

Host: xmpp.kids.dev:9090

Authorization: LXo8je4X

Content-Type: application/json

Cache-Control: no-cache

Postman-Token: 5d2539de-326c-8d7f-eabb-86dc226c722a

“{‘username’: ‘xx1’, ‘password’: ‘xx1’}”

You shouldn’t use the deprecated userservice inside of the rest api.

Please use in the path “/plugins/restapi/v1/” instead of “/plugins/userService”

Hi,

I am also getting 500(postman is being used) while creating the existing user. Openfire version 4.0.3, RestApi 1.2.4,

URL: http://example.org:9090/plugins/restapi/v1/users

Logs:

2017.01.17 01:15:07 org.jivesoftware.openfire.archive.Conversation - ORA-01400: cannot insert NULL into (“c_abc”.“OFCONPARTICIPANT”.“JIDRESOURCE”)

2017.01.17 00:30:08 org.jivesoftware.openfire.plugin.rest.exceptions.RESTExceptionMapper - UserAlreadyExistsException: Could not create new user with ressource abc123

I was expecting to get 409

Any help will be appreciated.

Can you please post here your full request? Otherwise it is really hard to reproduce it.

Thanks Redeyes for your quick response,

here is the full request,

POST /plugins/restapi/v1/users HTTP/1.1

Host: example.org:9090

Authorization: 123456

Content-Type: application/xml

Cache-Control: no-cache

Postman-Token: 9605215d-aecd-1366-9b6c-5ad8cf28d061

testuser121212

123456

Test User12

<email>test121212@localhost.de</email>

When user did not exist …it gave 201.

If user were created then it is giving 500 instead of 409.

Any help will be appreciated.

Hi aks,

by POST a user you should also add “Accept: application/xml”.

But the plugin should also better react on that