我有以下端点
@GET
@Produces(MediaType.APPLICATION_JSON)
public MyUserDetails haeKayttajatiedot() {
UserDetails details = (UserDetails) SecurityContextHolder.getContext().getAuthentication().getDetails();
LOGGER.debug("IstuntoREST.haeKayttajatiedot user: " + details.getUsername());
return new MyUserDetails(details);
}
我得到以下异常
MessageBodyProviderNotFoundException
但是,通过返回另一个域对象,我没有收到任何错误。这是引起错误的域对象
@XmlRootElement
public class MyUserDetails implements UserDetails {
@XmlTransient
private static final long serialVersionUID = 1L;
private String etunimi;
private String sukunimi;
@XmlTransient
private UserDetails baseUserDetails;
public MyUserDetails(UserDetails baseUserDetails) {
this.baseUserDetails = baseUserDetails;
}
@XmlElement
public String getEtunimi() {
return etunimi;
}
public void setEtunimi(String etunimi) {
this.etunimi = etunimi;
}
@XmlElement
public String getSukunimi() {
return sukunimi;
}
public void setSukunimi(String sukunimi) {
this.sukunimi = sukunimi;
}
@Override
@XmlElement
public Collection<? extends GrantedAuthority> getAuthorities() {
return baseUserDetails.getAuthorities();
}
@Override
@XmlTransient
public String getPassword() {
return baseUserDetails.getPassword();
}
@Override
@XmlElement
public String getUsername() {
return baseUserDetails.getUsername();
}
@Override
@XmlElement
public boolean isAccountNonExpired() {
return baseUserDetails.isAccountNonExpired();
}
@Override
@XmlElement
public boolean isAccountNonLocked() {
return baseUserDetails.isAccountNonLocked();
}
@Override
@XmlElement
public boolean isCredentialsNonExpired() {
return baseUserDetails.isCredentialsNonExpired();
}
@Override
@XmlElement
public boolean isEnabled() {
return baseUserDetails.isEnabled();
}
}
怎么了?