14

I have a program that inserts a new patient to HBase in a docker container inside a server. Everything is working fine until I try to change the connection IP to a phoenix query server for running JUnit tests. I am setting the URL in the properties file like this:

java.lang.RuntimeException: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') 
at [Source: java.io.StringReader@1105b1f; line: 1, column: 2] 
...
Caused by: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') at [Source: java.io.StringReader@1105b1f; line: 1, column: 2] 

I am not sure why I'm receiving a json parse exception. Because of the external apis, debugging didn't help. I don't even know if the exception is related to the format of the URL in my properties file, to the patient (which comes in xml format) or maybe even to the phoenix client.

I have started the phoenix query server and it looks like it can connect to it, because it was throwing a "connection refused" exception before and now it doesn't.

I added phoenix in my pom.xml like this:

<dependency>
    <groupId>org.apache.phoenix</groupId>
    <artifactId>phoenix-server</artifactId>
    <version>4.7.0-HBase-1.1</version>
</dependency>

but I don't know if I have to add something else for the phoenix-thin-client. If I have to, I couldn't find that dependency, so I just assumed it's included.

Any help is appreciated!

EDIT:

This is the exception the server throws:

> > 2016-05-05 08:52:11,979 WARN org.eclipse.jetty.server.HttpChannel: / java.lang.RuntimeException:
> org.apache.calcite.avatica.com.google.protobuf.InvalidProtocolBufferException:
> While parsing a protocol message, the input ended unexpectedly in the
> middle of a field.  This could mean either that the input has been
> truncated or that an embedded message misreported its own length.
>         at org.apache.calcite.avatica.remote.AbstractHandler.apply(AbstractHandler.java:98)
>         at org.apache.calcite.avatica.remote.ProtobufHandler.apply(ProtobufHandler.java:38)
>         at org.apache.calcite.avatica.server.AvaticaProtobufHandler.handle(AvaticaProtobufHandler.java:68)
>         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) Caused by: org.apache.calcite.avatica.com.google.protobuf.InvalidProtocolBufferException:
> While parsing a protocol message, the input ended unexpectedly in the
> middle of a field.  This could mean either that the input has been
> truncated or that an embedded message misreported its own length.
>         at org.apache.calcite.avatica.com.google.protobuf.InvalidProtocolBufferException.truncatedMessage(InvalidProtocolBufferException.java:70)
>         at org.apache.calcite.avatica.com.google.protobuf.CodedInputStream.skipRawBytesSlowPath(CodedInputStream.java:1293)
>         at org.apache.calcite.avatica.com.google.protobuf.CodedInputStream.skipRawBytes(CodedInputStream.java:1276)
>         at org.apache.calcite.avatica.com.google.protobuf.CodedInputStream.skipField(CodedInputStream.java:197)
>         at org.apache.calcite.avatica.com.google.protobuf.CodedInputStream.skipMessage(CodedInputStream.java:273)
>         at org.apache.calcite.avatica.com.google.protobuf.CodedInputStream.skipField(CodedInputStream.java:200)
>         at org.apache.calcite.avatica.proto.Common$WireMessage.<init>(Common.java:11627)
>         at org.apache.calcite.avatica.proto.Common$WireMessage.<init>(Common.java:11595)
>         at org.apache.calcite.avatica.proto.Common$WireMessage$1.parsePartialFrom(Common.java:12061)
>         at org.apache.calcite.avatica.proto.Common$WireMessage$1.parsePartialFrom(Common.java:12055)
>         at org.apache.calcite.avatica.com.google.protobuf.AbstractParser.parsePartialFrom(AbstractParser.java:137)
>         at org.apache.calcite.avatica.com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:168)
>         at org.apache.calcite.avatica.com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:180)
>         at org.apache.calcite.avatica.com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:185)
>         at org.apache.calcite.avatica.com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:49)
>         at org.apache.calcite.avatica.proto.Common$WireMessage.parseFrom(Common.java:11760)
>         at org.apache.calcite.avatica.remote.ProtobufTranslationImpl.parseRequest(ProtobufTranslationImpl.java:236)
>         at org.apache.calcite.avatica.remote.ProtobufHandler.decode(ProtobufHandler.java:42)
>         at org.apache.calcite.avatica.remote.ProtobufHandler.decode(ProtobufHandler.java:28)
>         at org.apache.calcite.avatica.remote.AbstractHandler.apply(AbstractHandler.java:95)
>         ... 11 more
3
  • 2
    You're probably getting html back. I don't see why debugging couldn't help... But you state you expect xml back-which isn't json. May 5, 2016 at 11:56
  • If debugging didn't work, you could try capturing the server response using a network sniffer.
    – Stephen C
    May 5, 2016 at 12:38
  • In my case it was due to the server down and throwing 404 Not Found. Please check your response code. Oct 6, 2017 at 10:50

2 Answers 2

1

Did you upgrade your Phoenix server properly? It looks like it trying to use both the JSON and Protocol Buffer protocols to connect. It should be one or the other.

3
  • I didn't change the serialization at all. I guess that's the problem then. Doing some debugging, I see that it's setting json as the phoenix.queryserver.serialization by default, but I don't know how to change that. Is it doing something like this in the connection? properties.setProperty("phoenix.queryserver.serialization", "PROTOBUF");
    – randombee
    May 5, 2016 at 16:22
  • 2
    try adding serialization=PROTOBUF in your jdbc connection string. Though I thought that would have been the default for both the server and client if both are version 4.7
    – kliew
    May 6, 2016 at 3:52
  • This worked. Apparently JSON was the default (or "someone else" is changing it somewhere and I'm not aware of it!). Thank you!!!
    – randombee
    May 6, 2016 at 9:12
1

Check if you are providing authorization, headers and other parameters correctly.

I solved by checking these steps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.