Project

General

Profile

there is a 500 error when run rest API /rest/pubsub/pubsub.10.206.25.251/publish-item

Livia Yu
Added 17 days ago

Dear sir,

we run command <Example 1","item-id":"publish1"}' "http://10.206.25.251:8080/rest/pubsub/pubsub.10.206.25.251/publish-item">> at liunx.
but there is a 500 error form the http response.
check the logs, found that there is a IndexOutOfBoundsException:

2019-01-04 13:30:37.653 [http-server-pool-1] RequestHandler.handle() FINEST: received request for path = /rest/pubsub/pubsub.10.206.25.251/publish-item
2019-01-04 13:30:37.655 [http-server-pool-1] RestExtServlet.processRequest() FINEST: comparing request URI = /rest/pubsub/pubsub.10.206.25.251/publish-item with /rest/pubsub
2019-01-04 13:30:37.660 [http-server-pool-1] java_util_logging_Logger$finest$2.call() FINEST: checking routings = [tigase.rest.pubsub.PubSubHandler@1174d8c0, tigase.rest.pubsub.PubSubActionsHandler@51e981] for prefix = /rest/pubsub and uri = /pubsub.10.206.25.251/publish-item
2019-01-04 13:30:37.661 [http-server-pool-1] java_util_logging_Logger$finest$2.call() FINEST: checking localUri = /pubsub.10.206.25.251/publish-item, prefix = /rest/pubsub, regex = /(?:([@/]+)@){0,1}([@/]+)
2019-01-04 13:30:37.663 [http-server-pool-1] java_util_logging_Logger$finest$2.call() FINEST: checking localUri = /pubsub.10.206.25.251/publish-item, prefix = /rest/pubsub, regex = /(?:([@/]+)@){0,1}([@/]+)/([/]+)
2019-01-04 13:30:37.663 [http-server-pool-1] java_util_logging_Logger$finest$2.call() FINEST: found handler
2019-01-04 13:30:37.678 [http-server-pool-1] java_util_logging_Logger$finest$2.call() FINEST: got calling with params = [tigase.http.ServiceImpl@55f864e9, tigase.http.rest.RestServlet$_execute_closure4@7b863814, tigase.http.java.DummyServletRequest@32503425, null, pubsub.10.206.25.251, publish-item]
2019-01-04 13:30:37.691 [http-server-pool-1] RequestHandler.handle() FINEST: Exception during processing HTTP request for id = 1
java.lang.RuntimeException: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at tigase.http.rest.RestExtServlet.processRequest(RestExtServlet.groovy:193)
at tigase.http.rest.RestExtServlet$processRequest$0.callCurrent(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:151)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:171)
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$14/1666996549.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 org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:110)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:122)
at tigase.rest.pubsub.PubSubActionsHandler.decodeContent(PubSubAdHocActions.groovy:267)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
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.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:151)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:163)
at tigase.rest.pubsub.PubSubActionsHandler$_closure3.doCall(PubSubAdHocActions.groovy:72)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
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.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:110)
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 org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:151)
at tigase.http.rest.RestServlet.executeAsync(RestServlet.groovy:186)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
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.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:151)
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.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
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.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:110)
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:189)
at tigase.http.rest.RestExtServlet$processRequest$0.callCurrent(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:151)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:171)
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$14/1666996549.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)

Could you help to check the error?

Thanks


Replies (3)

Added by Andrzej Wójcik IoT 1 CloudTigaseTeam 17 days ago

As far as I can tell (looking at the provided exception, you tried to send application/json encoded content to Tigase XMPP Server version 7.1.x which does not support JSON encoding for manipulating PubSub nodes and items. This version supports only application/xml encoded content for that.

Only version 8.0.0-SNAPSHOT or newer has support for application/json encoded content for calling REST API for PubSub.

Added by Livia Yu 16 days ago

Got it. Thanks for your timely reply. I have change the content type to xml and it run well.

Added by Livia Yu 16 days ago

Got it.

Thaks so much for your srong support.

    (1-3/3)