Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')

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
like image 984
randombee Avatar asked May 05 '16 11:05

randombee


2 Answers

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.

like image 52
kliew Avatar answered Oct 04 '22 04:10

kliew


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

I solved by checking these steps.

like image 24
Ajay Avatar answered Oct 04 '22 03:10

Ajay