Java JsonParseException: Unexpected character ('<' (code 60)): 应为有效值(数字、字符串、数组、对象、'true'、'false' 或 'null')
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37049956/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
提问by randombee
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:
我有一个程序可以在服务器内的 docker 容器中将新患者插入 HBase。一切正常,直到我尝试将连接 IP 更改为 phoenix 查询服务器以运行 JUnit 测试。我在属性文件中设置 URL,如下所示:
java.lang.RuntimeException: com.fasterxml.Hymanson.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.Hymanson.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.
我不确定为什么我会收到json
解析异常。由于外部 api,调试没有帮助。我什至不知道异常是否与我的属性文件中的 URL 格式、患者(以 xml 格式出现)或什至与 phoenix 客户端有关。
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.
我已经启动了 phoenix 查询服务器,看起来它可以连接到它,因为它之前抛出了“连接被拒绝”异常,现在它没有。
I added phoenix in my pom.xml like this:
我在 pom.xml 中添加了 phoenix,如下所示:
<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.run(AbstractConnection.java:540)
> at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
> at org.eclipse.jetty.util.thread.QueuedThreadPool.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.parsePartialFrom(Common.java:12061)
> at org.apache.calcite.avatica.proto.Common$WireMessage.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
采纳答案by kliew
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.
您是否正确升级了您的凤凰服务器?看起来它试图同时使用 JSON 和协议缓冲区协议进行连接。它应该是其中之一。
回答by Ajay
Check if you are providing authorization, headers and other parameters correctly.
检查您是否正确提供了授权、标题和其他参数。
I solvedby checking these steps.
我通过检查这些步骤解决了。