Neoh59
unread,Feb 22, 2012, 5:21:35 AM2/22/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to play-fr...@googlegroups.com
Hi all,
Could you help me on this problem.
I have a User entity with a photo member (Blob) ans some others members of course.
@Entity
public class User extends Model {
...
public Blob photo;
...
}
I override the save method, and want to resize the photo if needed :
@Override
public void _save() {
...
resizePhoto(); // Line 66
super._save();
}
The resizePhoto() method is :
private void resizePhoto() {
try {
if (photo != null) {
File photoFile = photo.getFile(); // Line 205
if (photoFile != null && photoFile.length() > getPhotoMaxSize()) {
// TODO
}
}
} catch (Exception e) {
Logger.warn("error when resizing photo for user %s : %s", username, e);
if (Logger.isDebugEnabled()) {
e.printStackTrace();
}
}
}
Each time a User is saved, an exception is thrown. Here is a part of the stack trace :
11:07:50,518 WARN ~ error when resizing photo for user 51000450 : java.lang.NullPointerException
java.lang.NullPointerException
at java.io.File.<init>(File.java:305)
at play.db.jpa.Blob.getFile(Blob.java:66)
at models.Employee.resizePhoto(Employee.java:205)
at models.Employee._save(Employee.java:197)
I check if photo member is not null. So why the line :
File photoFile = photo.getFile(); // Line 205
throws a NullPointerException ?
Thanks for your help