Reputation: 21
So I have tried returning multiple types of variables, including User, List and Response. All of these give me back a stackoverflow error in the get path page. I have found through the server log it is a serializing recursion, however I cannot seem to fix it, no matter how I try it. Have seen multiple online tutorials/pages on stackoverflow and still I can fix it.
I am running payara version 184 and java 8 ee, and these are project specifications, so I cant change the tecnologies. Intellij Idea Ultimate IDE and chrome browser/postman to check url.
public class User {
private String nome;
private int idade;
private String empresa;
private String email;
//private Boolean auth;
public User (String n , int i, String e, String em/*, Boolean a*/){
this.nome = n;
this.idade = i;
this. empresa = e;
this.email = em;
//this.auth = a;
}
public User getUser(){
return this;
}
interface for the restful class methods
@GET
@Path(ApplicationPaths.GET)
@Produces(MediaType.APPLICATION_JSON)
@APIResponse(responseCode = "200")
User getJson(
@Parameter(ref = Parameters.QUERY)
@QueryParam(Parameters.QUERY)
String query);
Actual class implementation
@ApplicationScoped
public class KickoffApiImpl implements KickoffApi {
@Inject
private KickoffService kickoffService;
@Override
public User getJson(final String query) {
/*
List<User> users = new ArrayList<>();
users.add(new User("pedro", 22, "ctw", "[email protected]"));
users.add(new User("paulo", 50, "ctw", "[email protected]"));
users.add(new User("maria", 32, "ctw", "[email protected]"));
return users.get(1);
*/
User u = new User("maria", 32, "ctw", "[email protected]");
return u;
//return Response.ok(kickoffService.getUser()).build();
}
My expected output would be a Json page with the 'User' class info on the browser.
P.S.: Server Log error: https://pastebin.com/xgRfazE9
Upvotes: 0
Views: 105
Reputation: 21
Ok, funny enough I solved my own question by looking at my post. So the recursion was due to the getUser method I implemented in the User class. TY if you tried to read and solve this.
Upvotes: 2