Projects tigase _server tigase-pubsub Issues #62
PubSub REST API doesn't work with JSON content (#62)
Closed
wojciech.kapcia@tigase.net opened 8 years ago
Due Date
2016-11-23

Following results in java.lang.IndexOutOfBoundsException

  • Call:
curl -X POST -d '{"data":{"node":"wojtek","owner":"admin@firefly"}}' http://admin%40firefly:pass@firefly:8080/rest/pubsub/pubsub.firefly/create-node --header "Content-Type:application/json"
  • Exception:
2016-11-16 17:50:36.496 [http-server-pool-7]  RequestHandler.handle()         FINEST:   Exception during processing HTTP request for id = 1377
java.lang.RuntimeException: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
        at tigase.http.rest.RestExtServlet.processRequest(RestExtServlet.groovy:190)
        at tigase.http.rest.RestExtServlet$processRequest$0.callCurrent(Unknown Source)
        at tigase.http.rest.RestServlet.service(RestServlet.groovy:95)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
        at tigase.http.java.RequestHandler.handle(RequestHandler.java:124)
        at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
        at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:83)
        at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:82)
        at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:675)
        at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
        at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:647)
        at tigase.http.java.JavaStandaloneHttpServer$ExecutorWithTimeout.lambda$0(JavaStandaloneHttpServer.java:187)
        at tigase.http.java.JavaStandaloneHttpServer$ExecutorWithTimeout$$Lambda$13/1117342116.run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
        at java.util.LinkedList.checkElementIndex(LinkedList.java:555)
        at java.util.LinkedList.get(LinkedList.java:476)
        at java_util_List$get$4.call(Unknown Source)
        at tigase.rest.pubsub.PubSubActionsHandler.decodeContent(PubSubAdHocActions.groovy:267)
        at sun.reflect.GeneratedMethodAccessor44.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:382)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
        at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:163)
        at tigase.rest.pubsub.PubSubActionsHandler$_closure3.doCall(PubSubAdHocActions.groovy:72)
        at sun.reflect.GeneratedMethodAccessor43.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
        at org.codehaus.groovy.runtime.metaclass.TransformMetaMethod.invoke(TransformMetaMethod.java:55)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass$1.invoke(ClosureMetaClass.java:279)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:292)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
        at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:39)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:122)
        at tigase.http.rest.RestServlet.execute(RestServlet.groovy:290)
        at tigase.http.rest.RestServlet$execute.callCurrent(Unknown Source)
        at tigase.http.rest.RestServlet.executeAsync(RestServlet.groovy:186)
        at sun.reflect.GeneratedMethodAccessor37.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:382)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
        at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:187)
        at tigase.http.rest.RestServlet$_processRequest_closure3.doCall(RestServlet.groovy:155)
        at sun.reflect.GeneratedMethodAccessor24.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:292)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
        at groovy.lang.Closure.call(Closure.java:423)
        at groovy.lang.Closure.call(Closure.java:439)
        at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2027)
        at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2012)
        at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2053)
        at org.codehaus.groovy.runtime.dgm$162.invoke(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:271)
        at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:122)
        at tigase.http.rest.RestServlet.processRequest(RestServlet.groovy:128)
        at tigase.http.rest.RestExtServlet.processRequest(RestExtServlet.groovy:186)
        at tigase.http.rest.RestExtServlet$processRequest$0.callCurrent(Unknown Source)
        at tigase.http.rest.RestServlet.service(RestServlet.groovy:95)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
        at tigase.http.java.RequestHandler.handle(RequestHandler.java:124)
        at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
        at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:83)
        at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:82)
        at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:675)
        at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
        at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:647)
        at tigase.http.java.JavaStandaloneHttpServer$ExecutorWithTimeout.lambda$0(JavaStandaloneHttpServer.java:187)
        at tigase.http.java.JavaStandaloneHttpServer$ExecutorWithTimeout$$Lambda$13/1117342116.run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Andrzej Wójcik (Tigase) commented 8 years ago

I added support for JSON requests in PubSub REST API with actions handling /rest/pubsub/{component}/{action}@. There was support for JSON using @/rest/pubsub/{component} but this required same format as in adhoc which was not easy to use.

I also updated documentation in asciidoc reflect changes in API

wojciech.kapcia@tigase.net commented 8 years ago

Works!

wojtek@atlantiscity.local ~/dev $ curl -H "Content-Type: application/json" -X POST -d '{"node":"wojtek/chat/H084LqAofoopG7sa-08","owner":"admin@atlantiscity"}' http://admin%40atlantiscity:admin@atlantiscity:8080/rest/pubsub/pubsub.atlantiscity/create-node
{
    "Note": "Operation successful"
}
issue 1 of 1
Type
Bug
Priority
Normal
Assignee
RedmineID
4727
Spent time
7h
Issue Votes (0)
Watchers (0)
Reference
tigase/_server/tigase-pubsub#62
Please wait...
Page is in error, reload to recover