javax.json.stream.JsonParsingException:org.glassfish.json.JsonTokenizer.readString期间出现意外的Char = Parse错误

时间:2015-03-27 18:36:48

标签: java json websocket glassfish base64

在使用基于websockets的编码器和解码器发送包含base64图像字符串的json对象期间,获得以下异常跟踪。 从ClientEndpoint到ServerEndpoint

问题:如何避免这个或任何替代解决方案通过websockets发送base64图像字符串?

import javax.websocket.EncodeException;
import javax.websocket.Encoder;
import javax.websocket.EndpointConfig;



public class MessageEncoder extends ServerObject implements    Encoder.Text<Message> {

    @Override
    public String encode(Message message) throws EncodeException {
        info("MessageEncoding -- {}",message.getJson());
        return message.getJson().toString();
    }

    @Override
    public void init(EndpointConfig config) {
        info("MessageEncoder init ");
    }

    @Override
    public void destroy() {
       info("MessageEncoder destroy ");
    }

}

可记录错误:

5-03-27 20:42:15,290 INFO  [stdout] (default I/O-8) B^No^MW P>R&@^H!6^M^M
2015-03-27 20:42:15,290 ERROR [stderr] (default I/O-8) javax.json.stream.JsonParsingException: Unexpected Char=31^M^M
2015-03-27 20:42:15,290 ERROR [stderr] (default I/O-8)  at org.glassfish.json.JsonTokenizer.readString(JsonTokenizer.java:180)^M^M
2015-03-27 20:42:15,290 ERROR [stderr] (default I/O-8)  at org.glassfish.json.JsonTokenizer.nextToken(JsonTokenizer.java:368)^M^M
2015-03-27 20:42:15,290 ERROR [stderr] (default I/O-8)  at org.glassfish.json.JsonParserImpl.nextToken(JsonParserImpl.java:154)^M^M
2015-03-27 20:42:15,291 ERROR [stderr] (default I/O-8)  at org.glassfish.json.JsonParserImpl.access$600(JsonParserImpl.java:60)^M^M
2015-03-27 20:42:15,291 ERROR [stderr] (default I/O-8)  at org.glassfish.json.JsonParserImpl$ObjectContext.getNextEvent(JsonParserImpl.java:258)^M^M
2015-03-27 20:42:15,291 ERROR [stderr] (default I/O-8)  at org.glassfish.json.JsonParserImpl$StateIterator.next(JsonParserImpl.java:180)^M^M
2015-03-27 20:42:15,291 ERROR [stderr] (default I/O-8)  at org.glassfish.json.JsonParserImpl.next(JsonParserImpl.java:149)^M^M
2015-03-27 20:42:15,291 ERROR [stderr] (default I/O-8)  at org.glassfish.json.JsonReaderImpl.readObject(JsonReaderImpl.java:176)^M

0 个答案:

没有答案