GridException: Cannot extract a capabilities from the request

Hi all!
I have a grid exception. It cannot extract capabilities. Tests are works fine, but sometimes nodes will not start the session.

Environment:

Appium 1.6.4 (1.6.5 has same issue)
selenium.version 3.4.0
appium.java.client.version 5.0.0-BETA8 (issue started to reproduce from 5.0.0-BETA6)

[details=Grid logs:]java -jar selenium-server-standalone-3.4.0.jar -role hub -port 4444
12:02:22.563 INFO - Selenium build info: version: ‘3.4.0’, revision: ‘unknown’
12:02:22.564 INFO - Launching Selenium Grid hub
2017-06-15 12:02:23.261:INFO::main: Logging initialized @991ms to org.seleniumhq.jetty9.util.log.StdErrLog
12:02:23.285 INFO - Will listen on 4444
2017-06-15 12:02:23.365:INFO:osjs.Server:main: jetty-9.4.3.v20170317
2017-06-15 12:02:23.413:INFO:osjs.session:main: DefaultSessionIdManager workerName=node0
2017-06-15 12:02:23.414:INFO:osjs.session:main: No SessionScavenger set, using defaults
2017-06-15 12:02:23.417:INFO:osjs.session:main: Scavenging every 600000ms
2017-06-15 12:02:23.426:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler@71d15f18{/,null,AVAILABLE}
2017-06-15 12:02:23.452:INFO:osjs.AbstractConnector:main: Started ServerConnector@7065cc2{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
2017-06-15 12:02:23.454:INFO:osjs.Server:main: Started @1184ms
12:02:23.455 INFO - Nodes should register to http://192.168.56.1:4444/grid/register/
12:02:23.455 INFO - Selenium Grid hub is up and running
12:02:38.423 INFO - Registered a node http://10.100.129.38:4733
2017-06-15 12:03:19.171:WARN:osjs.HttpChannel:qtp1539805781-11: /wd/hub/session
java.io.IOException: org.openqa.grid.common.exception.GridException: Cannot extract a capabilities from the request: {“capabilities”:[{“desiredCapabilities”:{“app”:"/Users/igor.petelsky/Downloads/com.[hide]lenovocom.android-2.4.3-204030-release.apk",“appPackage”:“com.[hide]lenovocom.android”,“appActivity”:“com.[hide].app.activity.MainActivity”,“clearSystemFiles”:true,“newCommandTimeout”:40,“autoGrantPermissions”:true,“udid”:“04157df458a3a03d”,“platformName”:“Android”,“deviceName”:“Phone_Galaxy_S6”,“fullReset”:true}},{“requiredCapabilities”:{}}],“desiredCapabilities”:{“app”:"/Users/igor.petelsky/Downloads/com.[hide]lenovocom.android-2.4.3-204030-release.apk",“appPackage”:“com.[hide]lenovocom.android”,“appActivity”:“com.[hide].app.activity.MainActivity”,“clearSystemFiles”:true,“newCommandTimeout”:40,“autoGrantPermissions”:true,“udid”:“04157df458a3a03d”,“platformName”:“Android”,“deviceName”:“Phone_Galaxy_S6”,“fullReset”:true},“requiredCapabilities”:{}}
at org.openqa.grid.web.servlet.DriverServlet.process(DriverServlet.java:126)
at org.openqa.grid.web.servlet.DriverServlet.doPost(DriverServlet.java:67)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.seleniumhq.jetty9.servlet.ServletHolder.handle(ServletHolder.java:841)
at org.seleniumhq.jetty9.servlet.ServletHandler.doHandle(ServletHandler.java:543)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
at org.seleniumhq.jetty9.server.session.SessionHandler.doHandle(SessionHandler.java:1584)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
at org.seleniumhq.jetty9.server.handler.ContextHandler.doHandle(ContextHandler.java:1228)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168)
at org.seleniumhq.jetty9.servlet.ServletHandler.doScope(ServletHandler.java:481)
at org.seleniumhq.jetty9.server.session.SessionHandler.doScope(SessionHandler.java:1553)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166)
at org.seleniumhq.jetty9.server.handler.ContextHandler.doScope(ContextHandler.java:1130)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.seleniumhq.jetty9.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.seleniumhq.jetty9.server.Server.handle(Server.java:564)
at org.seleniumhq.jetty9.server.HttpChannel.handle(HttpChannel.java:320)
at org.seleniumhq.jetty9.server.HttpConnection.onFillable(HttpConnection.java:251)
at org.seleniumhq.jetty9.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
at org.seleniumhq.jetty9.io.FillInterest.fillable(FillInterest.java:112)
at org.seleniumhq.jetty9.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
at org.seleniumhq.jetty9.util.thread.Invocable.invokePreferred(Invocable.java:122)
at org.seleniumhq.jetty9.util.thread.strategy.ExecutingExecutionStrategy.invoke(ExecutingExecutionStrategy.java:58)
at org.seleniumhq.jetty9.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:201)
at org.seleniumhq.jetty9.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:133)
at org.seleniumhq.jetty9.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:672)
at org.seleniumhq.jetty9.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:590)
at java.lang.Thread.run(Thread.java:748)
Caused by:
org.openqa.grid.common.exception.GridException: Cannot extract a capabilities from the request: {“capabilities”:[{“desiredCapabilities”:{“app”:"/Users/igor.petelsky/Downloads/com.[hide]lenovocom.android-2.4.3-204030-release.apk",“appPackage”:“com.[hide]lenovocom.android”,“appActivity”:“com.[hide].app.activity.MainActivity”,“clearSystemFiles”:true,“newCommandTimeout”:40,“autoGrantPermissions”:true,“udid”:“04157df458a3a03d”,“platformName”:“Android”,“deviceName”:“Phone_Galaxy_S6”,“fullReset”:true}},{“requiredCapabilities”:{}}],“desiredCapabilities”:{“app”:"/Users/igor.petelsky/Downloads/com.[hide]lenovocom.android-2.4.3-204030-release.apk",“appPackage”:“com.[hide]lenovocom.android”,“appActivity”:“com.[hide].app.activity.MainActivity”,“clearSystemFiles”:true,“newCommandTimeout”:40,“autoGrantPermissions”:true,“udid”:“04157df458a3a03d”,“platformName”:“Android”,“deviceName”:“Phone_Galaxy_S6”,“fullReset”:true},“requiredCapabilities”:{}}
at org.openqa.grid.web.servlet.handler.WebDriverRequest.extractDesiredCapability(WebDriverRequest.java:75)
at org.openqa.grid.web.servlet.handler.SeleniumBasedRequest.(SeleniumBasedRequest.java:102)
at org.openqa.grid.web.servlet.handler.WebDriverRequest.(WebDriverRequest.java:36)
at org.openqa.grid.web.servlet.handler.WebDriverRequestFactory.createFromRequest(WebDriverRequestFactory.java:30)
at org.openqa.grid.web.servlet.handler.SeleniumBasedRequest.createFromRequest(SeleniumBasedRequest.java:73)
at org.openqa.grid.web.servlet.DriverServlet.process(DriverServlet.java:81)
at org.openqa.grid.web.servlet.DriverServlet.doPost(DriverServlet.java:67)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.seleniumhq.jetty9.servlet.ServletHolder.handle(ServletHolder.java:841)
at org.seleniumhq.jetty9.servlet.ServletHandler.doHandle(ServletHandler.java:543)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
at org.seleniumhq.jetty9.server.session.SessionHandler.doHandle(SessionHandler.java:1584)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
at org.seleniumhq.jetty9.server.handler.ContextHandler.doHandle(ContextHandler.java:1228)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168)
at org.seleniumhq.jetty9.servlet.ServletHandler.doScope(ServletHandler.java:481)
at org.seleniumhq.jetty9.server.session.SessionHandler.doScope(SessionHandler.java:1553)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166)
at org.seleniumhq.jetty9.server.handler.ContextHandler.doScope(ContextHandler.java:1130)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.seleniumhq.jetty9.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.seleniumhq.jetty9.server.Server.handle(Server.java:564)
at org.seleniumhq.jetty9.server.HttpChannel.handle(HttpChannel.java:320)
at org.seleniumhq.jetty9.server.HttpConnection.onFillable(HttpConnection.java:251)
at org.seleniumhq.jetty9.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
at org.seleniumhq.jetty9.io.FillInterest.fillable(FillInterest.java:112)
at org.seleniumhq.jetty9.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
at org.seleniumhq.jetty9.util.thread.Invocable.invokePreferred(Invocable.java:122)
at org.seleniumhq.jetty9.util.thread.strategy.ExecutingExecutionStrategy.invoke(ExecutingExecutionStrategy.java:58)
at org.seleniumhq.jetty9.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:201)
at org.seleniumhq.jetty9.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:133)
at org.seleniumhq.jetty9.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:672)
at org.seleniumhq.jetty9.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:590)
at java.lang.Thread.run(Thread.java:748)
Caused by:
java.lang.ClassCastException: com.google.gson.JsonArray cannot be cast to com.google.gson.JsonObject
at com.google.gson.JsonObject.getAsJsonObject(JsonObject.java:191)
at org.openqa.grid.web.servlet.handler.WebDriverRequest.extractDesiredCapability(WebDriverRequest.java:69)
at org.openqa.grid.web.servlet.handler.SeleniumBasedRequest.(SeleniumBasedRequest.java:102)
at org.openqa.grid.web.servlet.handler.WebDriverRequest.(WebDriverRequest.java:36)
at org.openqa.grid.web.servlet.handler.WebDriverRequestFactory.createFromRequest(WebDriverRequestFactory.java:30)
at org.openqa.grid.web.servlet.handler.SeleniumBasedRequest.createFromRequest(SeleniumBasedRequest.java:73)
at org.openqa.grid.web.servlet.DriverServlet.process(DriverServlet.java:81)
at org.openqa.grid.web.servlet.DriverServlet.doPost(DriverServlet.java:67)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.seleniumhq.jetty9.servlet.ServletHolder.handle(ServletHolder.java:841)
at org.seleniumhq.jetty9.servlet.ServletHandler.doHandle(ServletHandler.java:543)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
at org.seleniumhq.jetty9.server.session.SessionHandler.doHandle(SessionHandler.java:1584)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
at org.seleniumhq.jetty9.server.handler.ContextHandler.doHandle(ContextHandler.java:1228)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168)
at org.seleniumhq.jetty9.servlet.ServletHandler.doScope(ServletHandler.java:481)
at org.seleniumhq.jetty9.server.session.SessionHandler.doScope(SessionHandler.java:1553)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166)
at org.seleniumhq.jetty9.server.handler.ContextHandler.doScope(ContextHandler.java:1130)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.seleniumhq.jetty9.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.seleniumhq.jetty9.server.Server.handle(Server.java:564)
at org.seleniumhq.jetty9.server.HttpChannel.handle(HttpChannel.java:320)
at org.seleniumhq.jetty9.server.HttpConnection.onFillable(HttpConnection.java:251)
at org.seleniumhq.jetty9.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
at org.seleniumhq.jetty9.io.FillInterest.fillable(FillInterest.java:112)
at org.seleniumhq.jetty9.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
at org.seleniumhq.jetty9.util.thread.Invocable.invokePreferred(Invocable.java:122)
at org.seleniumhq.jetty9.util.thread.strategy.ExecutingExecutionStrategy.invoke(ExecutingExecutionStrategy.java:58)
at org.seleniumhq.jetty9.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:201)
at org.seleniumhq.jetty9.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:133)
at org.seleniumhq.jetty9.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:672)
at org.seleniumhq.jetty9.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:590)
at java.lang.Thread.run(Thread.java:748)
2017-06-15 12:03:19.171:WARN:osjs.HttpChannel:qtp1539805781-13: /wd/hub/session
java.io.IOException: org.openqa.grid.common.exception.GridException: Cannot extract a capabilities from the request: {“capabilities”:[{“desiredCapabilities”:{“app”:"/Users/igor.petelsky/Downloads/com.[hide]lenovocom.android-2.4.3-204030-release.apk",“appPackage”:“com.[hide]lenovocom.android”,“appActivity”:“com.[hide].app.activity.MainActivity”,“clearSystemFiles”:true,“newCommandTimeout”:40,“autoGrantPermissions”:true,“udid”:“33003dcc58748265”,“platformName”:“Android”,“deviceName”:“Tablet_Galaxy_S2”,“fullReset”:true}},{“requiredCapabilities”:{}}],“desiredCapabilities”:{“app”:"/Users/igor.petelsky/Downloads/com.[hide]lenovocom.android-2.4.3-204030-release.apk",“appPackage”:“com.[hide]lenovocom.android”,“appActivity”:“com.[hide].app.activity.MainActivity”,“clearSystemFiles”:true,“newCommandTimeout”:40,“autoGrantPermissions”:true,“udid”:“33003dcc58748265”,“platformName”:“Android”,“deviceName”:“Tablet_Galaxy_S2”,“fullReset”:true},“requiredCapabilities”:{}}
at org.openqa.grid.web.servlet.DriverServlet.process(DriverServlet.java:126)
at org.openqa.grid.web.servlet.DriverServlet.doPost(DriverServlet.java:67)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.seleniumhq.jetty9.servlet.ServletHolder.handle(ServletHolder.java:841)
at org.seleniumhq.jetty9.servlet.ServletHandler.doHandle(ServletHandler.java:543)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
at org.seleniumhq.jetty9.server.session.SessionHandler.doHandle(SessionHandler.java:1584)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
at org.seleniumhq.jetty9.server.handler.ContextHandler.doHandle(ContextHandler.java:1228)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168)
at org.seleniumhq.jetty9.servlet.ServletHandler.doScope(ServletHandler.java:481)
at org.seleniumhq.jetty9.server.session.SessionHandler.doScope(SessionHandler.java:1553)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166)
at org.seleniumhq.jetty9.server.handler.ContextHandler.doScope(ContextHandler.java:1130)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.seleniumhq.jetty9.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.seleniumhq.jetty9.server.Server.handle(Server.java:564)
at org.seleniumhq.jetty9.server.HttpChannel.handle(HttpChannel.java:320)
at org.seleniumhq.jetty9.server.HttpConnection.onFillable(HttpConnection.java:251)
at org.seleniumhq.jetty9.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
at org.seleniumhq.jetty9.io.FillInterest.fillable(FillInterest.java:112)
at org.seleniumhq.jetty9.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
at org.seleniumhq.jetty9.util.thread.Invocable.invokePreferred(Invocable.java:122)
at org.seleniumhq.jetty9.util.thread.strategy.ExecutingExecutionStrategy.invoke(ExecutingExecutionStrategy.java:58)
at org.seleniumhq.jetty9.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:201)
at org.seleniumhq.jetty9.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:133)
at org.seleniumhq.jetty9.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:672)
at org.seleniumhq.jetty9.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:590)
at java.lang.Thread.run(Thread.java:748)
Caused by:
org.openqa.grid.common.exception.GridException: Cannot extract a capabilities from the request: {“capabilities”:[{“desiredCapabilities”:{“app”:"/Users/igor.petelsky/Downloads/com.[hide]lenovocom.android-2.4.3-204030-release.apk",“appPackage”:“com.[hide]lenovocom.android”,“appActivity”:“com.[hide].app.activity.MainActivity”,“clearSystemFiles”:true,“newCommandTimeout”:40,“autoGrantPermissions”:true,“udid”:“33003dcc58748265”,“platformName”:“Android”,“deviceName”:“Tablet_Galaxy_S2”,“fullReset”:true}},{“requiredCapabilities”:{}}],“desiredCapabilities”:{“app”:"/Users/igor.petelsky/Downloads/com.[hide]lenovocom.android-2.4.3-204030-release.apk",“appPackage”:“com.[hide]lenovocom.android”,“appActivity”:“com.[hide].app.activity.MainActivity”,“clearSystemFiles”:true,“newCommandTimeout”:40,“autoGrantPermissions”:true,“udid”:“33003dcc58748265”,“platformName”:“Android”,“deviceName”:“Tablet_Galaxy_S2”,“fullReset”:true},“requiredCapabilities”:{}}
at org.openqa.grid.web.servlet.handler.WebDriverRequest.extractDesiredCapability(WebDriverRequest.java:75)
at org.openqa.grid.web.servlet.handler.SeleniumBasedRequest.(SeleniumBasedRequest.java:102)
at org.openqa.grid.web.servlet.handler.WebDriverRequest.(WebDriverRequest.java:36)
at org.openqa.grid.web.servlet.handler.WebDriverRequestFactory.createFromRequest(WebDriverRequestFactory.java:30)
at org.openqa.grid.web.servlet.handler.SeleniumBasedRequest.createFromRequest(SeleniumBasedRequest.java:73)
at org.openqa.grid.web.servlet.DriverServlet.process(DriverServlet.java:81)
at org.openqa.grid.web.servlet.DriverServlet.doPost(DriverServlet.java:67)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.seleniumhq.jetty9.servlet.ServletHolder.handle(ServletHolder.java:841)
at org.seleniumhq.jetty9.servlet.ServletHandler.doHandle(ServletHandler.java:543)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
at org.seleniumhq.jetty9.server.session.SessionHandler.doHandle(SessionHandler.java:1584)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
at org.seleniumhq.jetty9.server.handler.ContextHandler.doHandle(ContextHandler.java:1228)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168)
at org.seleniumhq.jetty9.servlet.ServletHandler.doScope(ServletHandler.java:481)
at org.seleniumhq.jetty9.server.session.SessionHandler.doScope(SessionHandler.java:1553)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166)
at org.seleniumhq.jetty9.server.handler.ContextHandler.doScope(ContextHandler.java:1130)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.seleniumhq.jetty9.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.seleniumhq.jetty9.server.Server.handle(Server.java:564)
at org.seleniumhq.jetty9.server.HttpChannel.handle(HttpChannel.java:320)
at org.seleniumhq.jetty9.server.HttpConnection.onFillable(HttpConnection.java:251)
at org.seleniumhq.jetty9.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
at org.seleniumhq.jetty9.io.FillInterest.fillable(FillInterest.java:112)
at org.seleniumhq.jetty9.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
at org.seleniumhq.jetty9.util.thread.Invocable.invokePreferred(Invocable.java:122)
at org.seleniumhq.jetty9.util.thread.strategy.ExecutingExecutionStrategy.invoke(ExecutingExecutionStrategy.java:58)
at org.seleniumhq.jetty9.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:201)
at org.seleniumhq.jetty9.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:133)
at org.seleniumhq.jetty9.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:672)
at org.seleniumhq.jetty9.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:590)
at java.lang.Thread.run(Thread.java:748)
Caused by:
java.lang.ClassCastException: com.google.gson.JsonArray cannot be cast to com.google.gson.JsonObject
at com.google.gson.JsonObject.getAsJsonObject(JsonObject.java:191)
at org.openqa.grid.web.servlet.handler.WebDriverRequest.extractDesiredCapability(WebDriverRequest.java:69)
at org.openqa.grid.web.servlet.handler.SeleniumBasedRequest.(SeleniumBasedRequest.java:102)
at org.openqa.grid.web.servlet.handler.WebDriverRequest.(WebDriverRequest.java:36)
at org.openqa.grid.web.servlet.handler.WebDriverRequestFactory.createFromRequest(WebDriverRequestFactory.java:30)
at org.openqa.grid.web.servlet.handler.SeleniumBasedRequest.createFromRequest(SeleniumBasedRequest.java:73)
at org.openqa.grid.web.servlet.DriverServlet.process(DriverServlet.java:81)
at org.openqa.grid.web.servlet.DriverServlet.doPost(DriverServlet.java:67)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.seleniumhq.jetty9.servlet.ServletHolder.handle(ServletHolder.java:841)
at org.seleniumhq.jetty9.servlet.ServletHandler.doHandle(ServletHandler.java:543)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
at org.seleniumhq.jetty9.server.session.SessionHandler.doHandle(SessionHandler.java:1584)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
at org.seleniumhq.jetty9.server.handler.ContextHandler.doHandle(ContextHandler.java:1228)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168)
at org.seleniumhq.jetty9.servlet.ServletHandler.doScope(ServletHandler.java:481)
at org.seleniumhq.jetty9.server.session.SessionHandler.doScope(SessionHandler.java:1553)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166)
at org.seleniumhq.jetty9.server.handler.ContextHandler.doScope(ContextHandler.java:1130)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.seleniumhq.jetty9.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.seleniumhq.jetty9.server.Server.handle(Server.java:564)
at org.seleniumhq.jetty9.server.HttpChannel.handle(HttpChannel.java:320)
at org.seleniumhq.jetty9.server.HttpConnection.onFillable(HttpConnection.java:251)
at org.seleniumhq.jetty9.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
at org.seleniumhq.jetty9.io.FillInterest.fillable(FillInterest.java:112)
at org.seleniumhq.jetty9.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
at org.seleniumhq.jetty9.util.thread.Invocable.invokePreferred(Invocable.java:122)
at org.seleniumhq.jetty9.util.thread.strategy.ExecutingExecutionStrategy.invoke(ExecutingExecutionStrategy.java:58)
at org.seleniumhq.jetty9.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:201)
at org.seleniumhq.jetty9.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:133)
at org.seleniumhq.jetty9.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:672)
at org.seleniumhq.jetty9.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:590)
at java.lang.Thread.run(Thread.java:748)
12:03:19.375 INFO - Got a request to create a new session: Capabilities [{app=/Users/igor.petelsky/Downloads/com.[hide]lenovocom.android-2.4.3-204030-release.apk, appPackage=com.[hide]lenovocom.android, appActivity=com.[hide].app.activity.MainActivity, clearSystemFiles=true, newCommandTimeout=40, autoGrantPermissions=true, udid=04157df458a3a03d, platformName=Android, deviceName=Phone_Galaxy_S6, fullReset=true}]
12:03:19.375 INFO - Got a request to create a new session: Capabilities [{app=/Users/igor.petelsky/Downloads/com.[hide]lenovocom.android-2.4.3-204030-release.apk, appPackage=com.[hide]lenovocom.android, appActivity=com.[hide].app.activity.MainActivity, clearSystemFiles=true, newCommandTimeout=40, autoGrantPermissions=true, udid=33003dcc58748265, platformName=Android, deviceName=Tablet_Galaxy_S2, fullReset=true}]
12:03:19.376 INFO - Trying to create a new session on test slot {browserName=Galaxy_Tab_S_2, maxInstances=1, version=6.0.1, platform=ANDROID}
^C%[/details]

Capabilities:

@Parameters({"ID", "DEVICE_NAME"})
@BeforeClass
public void setUp(@Optional String id, @Optional String deviceName) throws Exception {
    this.deviceName = deviceName;

    DesiredCapabilities capabilities = new DesiredCapabilities();
    logger.info("Set up capability for " + deviceName);
    capabilities.setCapability(MobileCapabilityType.APP, APP_PATH);
    capabilities.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, APP_PACKAGE);
    capabilities.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, APP_ACTIVITY);
    capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, deviceName);
    capabilities.setCapability(MobileCapabilityType.UDID, id);
    capabilities.setCapability(MobileCapabilityType.FULL_RESET, true);
    capabilities.setCapability("autoGrantPermissions", true);
    capabilities.setCapability("clearSystemFiles", true);
    capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, COMMAND_TIMEOUT);
    capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, PLATFORM);
    logger.info("Starts android driver for " + deviceName);
    androidDriver = (new AndroidDriver(new URL(DRIVER_URL), capabilities));

    if (deviceName.contains(TABLET)) {
        androidDriver.rotate(ScreenOrientation.LANDSCAPE);
        logger.info("Changed rotation to 'landscape' for " + deviceName);
    }

    if (deviceName.contains(PHONE)) {
        androidDriver.rotate(ScreenOrientation.PORTRAIT);
        logger.info("Changed rotation to 'portrait' for " + deviceName);
    }

    androidDriver.manage().timeouts().implicitlyWait(IMPLICITLY_WAIT, TimeUnit.SECONDS);
}

NodeConfig:

{
“capabilities”:
[{
“browserName”: “Galaxy_Tab_S_2”,
“version”: “6.0.1”,
“maxInstances”: 1,
“platform”: “ANDROID”
}],
“configuration”:
{
“cleanUpCycle”: 2000,
“timeout”: 30000,
“proxy”: “org.openqa.grid.selenium.proxy.DefaultRemoteProxy”,
“host”: “10.100.129.38”,
“role”: “node”,
“nodeStatusCheckTimeout”: 30000,
“port”: 4733,
“url”: “http://10.100.129.38:4733/wd/hub”,
“maxSession”: 1,
“register”: true,
“registerCycle”: 10000,
“hubPort”: 4444,
“hubHost”: “10.100.129.38”,
“hub”: “http://10.100.129.38:4444/grid/register
}
}

Watch this : https://youtu.be/vXpskMkytD8