java.lang.InstantiationError:com.google.protobuf.LazyStringList

时间:2019-08-04 01:19:49

标签: java protocol-buffers protobuf-java protostuff

当我尝试使用Probruf反序列化protobuf时遇到问题
    ProtobufIOUtil.mergeFrom(decodedString,TSchemaObject,tsschema);

here is my .proto file

syntax = "proto2";
option java_package = "com.xyzschema";
option java_outer_classname = "TSchema";

message TS {
    optional ts ts = 2;
}

message ts {
    optional Events Events = 1;
    repeated string flight_time = 2;
    optional string view_id = 3;
}


message Events {
    optional bool x = 1;
    optional bool y = 2;

}

repeated string flight_time = 2; is the one giving problems

我使用此将JSON转换为pb      byte []数据=
     ProtobufIOUtil.toByteArray(ts.build(),schema,buffer);

但是一旦我将其转换,我想从字节中取回pb []

    ProtobufIOUtil.mergeFrom(data, TSObject, tsschema);

I am using the following dependencies
<dependency>
            <groupId>com.dyuproject.protostuff</groupId>
            <artifactId>protostuff-api</artifactId>
            <version>1.0.8</version>
        </dependency>
        <dependency>
            <groupId>com.dyuproject.protostuff</groupId>
            <artifactId>protostuff-runtime</artifactId>
            <version>1.0.8</version>
        </dependency>

        <dependency>
            <groupId>com.dyuproject.protostuff</groupId>
            <artifactId>protostuff-core</artifactId>
            <version>1.0.8</version>
        </dependency>

        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java</artifactId>
            <version>3.1.0</version>
        </dependency>

com.dyuproject.protostuff.runtime.RuntimeEnv$DefaultInstantiator.newInstance(RuntimeEnv.java:300)
    at com.dyuproject.protostuff.runtime.DefaultIdStrategy$RuntimeCollectionFactory.newMessage(DefaultIdStrategy.java:553)
    at com.dyuproject.protostuff.runtime.RuntimeRepeatedFieldFactory$5.setValue(RuntimeRepeatedFieldFactory.java:451)
    at com.dyuproject.protostuff.runtime.PolymorphicSchemaFactories$8$1.setValue(PolymorphicSchemaFactories.java:145)
    at com.dyuproject.protostuff.runtime.ObjectSchema.mergeFrom(ObjectSchema.java:312)
    at com.dyuproject.protostuff.ByteArrayInput.mergeObject(ByteArrayInput.java:375)
    at com.dyuproject.protostuff.runtime.RuntimeRepeatedFieldFactory$5.mergeFrom(RuntimeRepeatedFieldFactory.java:385)
    at com.dyuproject.protostuff.runtime.MappedSchema.mergeFrom(MappedSchema.java:196)
    at com.dyuproject.protostuff.ByteArrayInput.mergeObject(ByteArrayInput.java:375)
    at com.dyuproject.protostuff.runtime.RuntimeUnsafeFieldFactory$13$1.mergeFrom(RuntimeUnsafeFieldFactory.java:787)
    at com.dyuproject.protostuff.runtime.MappedSchema.mergeFrom(MappedSchema.java:196)
    at com.dyuproject.protostuff.IOUtil.mergeFrom(IOUtil.java:43)
    at com.dyuproject.protostuff.ProtobufIOUtil.mergeFrom(ProtobufIOUtil.java:95)

0 个答案:

没有答案