在运行GAE + PrimeFaces + Spring + Maven的BookList应用程序时,
使用JDO将书名和作者保存到数据存储区时出错。
喜欢,

**Oct 25, 2011 11:10:24 AM javax.faces.event.MethodExpressionActionListener processAction
SEVERE: Received 'java.lang.NullPointerException' when invoking action listener '#                   {createBook.save}' for component 'j_idt11'
Oct 25, 2011 11:10:24 AM javax.faces.event.MethodExpressionActionListener processAction
SEVERE: java.lang.NullPointerException**

error with the highlighted line.Please give a solution.

public void save(ActionEvent actionEvent) {
System.out.println("in actionEvent");

**bookDAO.persist(book);** //getting values here correctly.But cannot save!
FacesMessage facesMessage = new FacesMessage(FacesMessage.SEVERITY_INFO, "Info", "Book is saved");
FacesContext.getCurrentInstance().addMessage(null, facesMessage);
book = new MyBook();
}

thanks.

最佳答案

这表明bookDAO可能为空。这是要检查的第一件事...如何设置bookDAO字段?

09-27 00:49