I am facing a weird issue in my application which runs on Spring Boot 1.4.0M3 which is using Spring cache implementation where provider is Redis where I receive classCastException that same object cannot be casted
I am using Mongodb as database and I have User Object which contains List of Roles object loaded lazily and Roles internally contains Permissions Object like below
@Document
@Data
public class User implements Serializable{
private String passwordResetToken;
private boolean enabled = false;
@DBRef(lazy= true)
private List<Role> roleList;
}
My Role DTO is as below
@Data
@Document
public class Role implements Serializable{
private String roleName;
private String description;
@DBRef(lazy= true)
private List<Permission> permissions;
}
Now in my spring MVC while loading all roles I am calling all permissions and since this is repetitive operation I thought of caching the result and using redis and while loading the roles value I receive below exception.
raised java.lang.ClassCastException: com.learning.securedapp.domain.Permission cannot be cast to com.learning.securedapp.domain.Permission
Help me to overcome this error.
I am attaching the source code to my project and I receive error at line 91 of RoleController.java
To Replicate in your local environment login to application and click on permissions menu and then roles menu, In Roles menu now click on any edit icon.you will receive above error.