Hello everyone i have a simple problem where i cant seem to convert a zookeeper object into json and vice versa using GSON library in jersey for java web services.The error i get is
Exception in thread "main" java.lang.StackOverflowError
at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:381)
at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:376)
at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:381)
at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:376)
and it keeps going on pretty large. From what i have searched this semms to be the issue of too deeply nested objects and recursion. Here's what i tried for a simple POC
ZooKeeper zoo;
try {
zoo = new ZooKeeper("localhost:2182",5000,null);
String obj=gson.toJson(zoo, ZooKeeper.class);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
can someone clearly explain what is the actual problem and even if its possible to convert and use zookeeper objects as json(because of all the threads associated with it)