In short
I need to find the root cause of the error messages which is displayed in the spring data rest. How to find the exact place where I should put @JsonIgnore
, or @RestResource(exported = false)
by looking at the generic error message?
In Detail
I embed my Spring Application with spring data rest
. Though there are many entities and repositories, I only wanted few entities to get exposed via rest. One of the entity is user
.
But I get the following error message. How can I drill down to the place where I can actually find the root cause of this generic error message?
Could not write content: Infinite recursion (StackOverflowError) (through reference chain: org.springframework.hateoas.Resources["_embedded"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Infinite recursion (StackOverflowError) (through reference chain: org.springframework.hateoas.Resources["_embedded"])
Repository
@RepositoryRestResource(collectionResourceRel = "system-users", itemResourceRel = "system-user", path = "system-users")
public interface UserRepository extends CrudRepository<User, Long>, DatatablesCriteriasRepository<User>{
@RestResource(exported = false)
@Query("SELECT u FROM User u INNER JOIN u.roles role WHERE role.role in :roles")
Iterable<User> findByRoles(@Param("roles") String... roles);
@RestResource(exported = false)
@Query("SELECT u FROM User u WHERE u.username = :username")
User findByUsername(@Param("username") String username);
...
...
}
Model
@Entity
@Table(name = "system_user_tab")
public class User{
...
...
I know by using @JsonIgnore
, @RestResource(exported = false)
I can try to eliminate the issue. But I need to know how I can understand the exact place where I have to use these annotations, by looking at this error message.