Agradeço se alguém puder ajudar...
Arquivo livro.xhtml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:body>
<h1>Novo Livro</h1>
<h:form>
<fieldset>
<legend>Dados do Livro</legend>
<h:panelGrid columns="2">
<h:outputLabel value="Titulo:" for="titulo" />
<h:inputText id="titulo" value="#{livroBean.livro.titulo}" />
<h:outputLabel value="ISBN:" for="isbn" />
<h:inputText id="isbn" value="#{livroBean.livro.isbn}" />
<h:outputLabel value="Preço:" for="preco" />
<h:inputText id="preco" value="#{livroBean.livro.preco}" />
<h:outputLabel value="Data de Lançamento:" for="dataLancamento" />
<h:inputText id="dataLancamento"
value="#{livroBean.livro.dataLancamento}" />
</h:panelGrid>
</fieldset>
<fieldset>
<legend>Dados do Autor</legend>
<h:outputLabel value="Selecione Autor:" for="autor" />
<h:selectOneMenu>
<f:selectItems value="#{livroBean.autores}" var="autor"
itemLabel="#{autor.nome}" itemValue="#{autor.id}"/>
</h:selectOneMenu>
<h:commandButton value="Gravar Autor" />
</fieldset>
<h:commandButton value="Gravar" action="#{livroBean.gravar}" />
</h:form>
</h:body>
</html>
LivroBean:
package br.com.caelum.livraria.bean;
import java.util.List;
import javax.faces.bean.ManagedBean;
import br.com.caelum.livraria.dao.DAO;
import br.com.caelum.livraria.modelo.Autor;
import br.com.caelum.livraria.modelo.Livro;
@ManagedBean
public class LivroBean {
private Livro livro = new Livro();
public Livro getLivro() {
return livro;
}
public void gravar() {
System.out.println("Gravando livro " + this.livro.getTitulo());
if (livro.getAutores().isEmpty()) {
throw new RuntimeException("Livro deve ter pelo menos um Autor.");
}
new DAO<Livro>(Livro.class).adiciona(this.livro);
}
public List<Autor> getAutores(){
List<Autor> autores = new DAO<Autor>(Autor.class).listaTodos();
System.out.println(autores);
return autores;
}
}
Mensagens do Console:
...
GRAVE: Error Rendering View[/livro.xhtml]
javax.el.ELException: /livro.xhtml @35,57 value="#{livroBean.autores}": Error reading [autores] on type [br.com.caelum.livraria.bean.LivroBean]
...