Your problem is different than what the book tells. If JSF/EL couldn't find the getter method in its entirety, you would have gotten the below exception:
javax.el.PropertyNotFoundException: Property 'books' not found on type pl.ctrl.BookController
Or if it couldn't find the bean itself in its entirety:
javax.el.PropertyNotFoundException: Target Unreachable, identifier 'bookController' resolved to null
But instead you got:
javax.el.ELException: Error reading 'books' on type pl.ctrl.BookController
This means that the bean and the getter method was found, but invoking the getter method threw an exception. Basically, the following is happening under JSF/EL's covers:
try {
Object result = bookController.getBooks();
} catch (Exception e) {
throw new ELException("Error reading 'books' on type pl.ctrl.BookController", e);
}
Note the e
being passed as cause of the ELException
. The original exception must thus be visible as "Caused by" further down in the stack trace which you didn't post anywhere in the question. The bottommost one is the root cause of all and is the answer to your concrete problem. In case you're unable to interpret it, simply copypaste the exception type and message into a decent search engine to find answers and clues.
Unrelated to the concrete problem, an exception thrown from a getter method in turn indicates fishy code. A getter method isn't supposed to do any exception sensitive business logic. Namely, it can be invoked multiple times per bean's life and repeating the very same business logic over and over during all bean's life is plain inefficient. Stop doing that and move the business logic to an one time initialization or action/event listener method. The getter method must merely return the already-prepared property. See also Why JSF calls getters multiple times and How and when should I load the model from database for h:dataTable.
getBooks()
method, you effectively define abooks
property. What you don't necessarily define is thebooks
field. A field and a property are not the same thing. – Desolate