phoenix-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Terrell <sterr...@oculus360.us>
Subject Phoenix Query Server and/or Avatica Bug and/or My Misunderstanding
Date Fri, 05 Feb 2016 05:30:48 GMT
I can query Phoenix by doing something like this:

curl -v -XPOST -H 'request:
{"request":"prepareAndExecute","connectionId":"aaa","sql":"select * from
CAT_MAP"}' http://10.0.100.57:8765/


However, I am unable to make such a request in Javascript in my web page
because the POST method, along with a custom header, trigger CORS security
in modern browsers which do a "method OPTIONS" preflight request, which is
not handled by the Phoenix Query Server (that I know of).

I dug and dug and dug and found some Avatica source code that made it look
like one should be able to put the JSON into the post data instead of the
header, and it should work.  (See lines 78-89 in
https://github.com/apache/calcite/blob/master/avatica-server/src/main/java/org/apache/calcite/avatica/server/AvaticaJsonHandler.java
).  I don't know if this is the version of Avatica that PQS uses, but it
sounded like a good chance this feature would persist through many versions.

So I tried this:

curl -v -XPOST -H 'Content-Type: text/plain' -d
'{"request":"prepareAndExecute","connectionId":"aaa","sql":"select * from
CAT_MAP"}' http://10.0.100.57:8765/


But I got an "HTTP/1.1 500 Server Error".  Further more, the request caused
this in the PQS logs:
2016-02-05 05:22:58,085 WARN org.eclipse.jetty.server.HttpChannel: /

java.lang.NullPointerException
at java.io.StringReader.<init>(StringReader.java:50)
at
com.fasterxml.jackson.core.JsonFactory.createJsonParser(JsonFactory.java:917)
at
com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:1942)
at org.apache.calcite.avatica.remote.JsonHandler.decode(JsonHandler.java:51)
at org.apache.calcite.avatica.remote.JsonHandler.apply(JsonHandler.java:42)
at
org.apache.calcite.avatica.server.AvaticaHandler.handle(AvaticaHandler.java:55)
at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52)
at
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:497)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
at
org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:245)
at
org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
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)


Does anyone know if I am doing something wrong?

Thanks,
    Steve

Mime
View raw message