BeanUtils.copyProperties()
throw NullPointerException
on Tomcat, but on localhost it works fine.
I've checked everything and dto
isn't null
, only the properties of user is null
which is fine.
public void saveUser(UserDTO dto) {
User user = new User();
BeanUtils.copyProperties(dto, user);
session.beginTransaction();
session.save(user);
session.getTransaction().commit();
}
my User.java
public class User {
@Id @GeneratedValue
private long id;
private String userId;
private String firstName;
private String lastName;
private String email;
@Enumerated(EnumType.STRING)
private Role role;
private String encryptedPassword;
private String salt;
private String token;
... getters and setters method ...
}