murdos / easy-random-protobuf Goto Github PK
View Code? Open in Web Editor NEWEasy Random protobuf support
License: Apache License 2.0
Easy Random protobuf support
License: Apache License 2.0
Hello,
I'm actually trying to use your amazing library but without success.
I used the exact same example you put in your README.
I have a class that has a property of type MapEntry (from com.google.protobuf) in it. And whenever I try to randomize it I keep getting this error:
org.jeasy.random.ObjectCreationException: Unable to create a random instance of type class openmatch.Messages$Assignment
...
Caused by: org.jeasy.random.ObjectCreationException: Unable to create a random instance of type class com.google.protobuf.MapEntry
at app//org.jeasy.random.EasyRandom.doPopulateBean(EasyRandom.java:172)
at app//org.jeasy.random.EasyRandom.nextObject(EasyRandom.java:100)
at app//io.github.murdos.easyrandom.protobuf.ProtobufMessageRandomizer.lambda$new$8(ProtobufMessageRandomizer.java:77)
at app//io.github.murdos.easyrandom.protobuf.ProtobufMessageRandomizer.populateField(ProtobufMessageRandomizer.java:121)
at app//io.github.murdos.easyrandom.protobuf.ProtobufMessageRandomizer.getRandomValue(ProtobufMessageRandomizer.java:95)
at app//io.github.murdos.easyrandom.protobuf.ProtobufMessageRandomizer.getRandomValue(ProtobufMessageRandomizer.java:43)
at app//org.jeasy.random.EasyRandom.doPopulateBean(EasyRandom.java:133)
... 88 more
Caused by: java.lang.IllegalArgumentException: java.lang.NoSuchMethodException: com.google.protobuf.MapEntry.getDefaultInstance()
at io.github.murdos.easyrandom.protobuf.ProtobufMessageRandomizer.instantiateMessage(ProtobufMessageRandomizer.java:108)
at io.github.murdos.easyrandom.protobuf.ProtobufMessageRandomizer.getRandomValue(ProtobufMessageRandomizer.java:85)
at io.github.murdos.easyrandom.protobuf.ProtobufMessageRandomizer.getRandomValue(ProtobufMessageRandomizer.java:43)
at org.jeasy.random.EasyRandom.doPopulateBean(EasyRandom.java:133)
... 94 more
Caused by: java.lang.NoSuchMethodException: com.google.protobuf.MapEntry.getDefaultInstance()
at java.base/java.lang.Class.getMethod(Class.java:2108)
at io.github.murdos.easyrandom.protobuf.ProtobufMessageRandomizer.instantiateMessage(ProtobufMessageRandomizer.java:105)
... 97 more
Do you, by chance, have already been facing that kind of problem? and is there any solution/workaround?
Thanks
First of all thanks for this plugin, it seems to be really helpful!
Sadly I have some problems to get it working in my project, I always get the following error message:
org.jeasy.random.ObjectCreationException: Unable to create a random instance of type class com.igdb.proto.Igdb$InvolvedCompany
I uploaded a small sample project to reproduce this error here: https://github.com/grimsi/easyrandom-protobuf-test
Simply running a mvn clean install
will result in a Stack-Overflow and "Unable to create a random instance of type class XXX".
I am using the official protobuf file from IGDB and it works fine in my project: https://api.igdb.com/v4/igdbapi.proto
I am using the protoc-jar-maven-plugin
to compile the .proto file to Java classes.
My project is using Java 18 (maybe that's an issue?).
If you need any further assistance just tell me and I will give my best to support you.
In addition to message generation
https://github.com/j-easy/easy-random/wiki/excluding-fields is currently not supported for generating Protobuf message
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.