Olá,
Estou recebendo uma exception na aula de conversão de data e não consigo encontrar o porque:
HTTP Status 500 - javax.el.PropertyNotFoundException: /livro.xhtml @21,85 value="#{livroBean.livro.dataLancamento.time}": Target Unreachable, 'dataLancamento' returned nullPela mensagem da exception, não consegui acessar o valor por causa do atributo dataLancamente estar nulo, não entendo o porque.
Minha view:
<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 Lancamento" for="dataLancamento" />
                <h:inputText id="dataLancamento" value="#{livroBean.livro.dataLancamento.time}">
                    <f:convertDateTime pattern="dd/MM/yyyy" timeZone="America/Sao_Paulo" />
                </h:inputText>
            </h:panelGrid>
            <h:commandButton value="Gravar" action="#{livroBean.gravar}" />
        </fieldset>Meu Bean:
package br.com.alura.livraria.bean;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.persistence.EntityManager;
import br.com.alura.livraria.dao.AutorDAO;
import br.com.alura.livraria.dao.LivroDAO;
import br.com.alura.livraria.model.Autor;
import br.com.alura.livraria.model.Livro;
import br.com.alura.livraria.util.JpaUtil;
@ManagedBean(name="livroBean")
@ViewScoped
public class LivroBean {
    private Livro livro = new Livro();
    private List<Livro> livros;
    private List<Autor> autores;
    private Integer autorId;
    private EntityManager em = new JpaUtil().getEntityManager();
    AutorDAO autorDAO = new AutorDAO(em);
    LivroDAO livroDAO = new LivroDAO(em);
    public List<Autor> getAutores() {        
        if(autores == null){            
            autores = autorDAO.obterTodosAutores();            
        }
        return autores;
    }
    public List<Livro> getLivros() {
        livros = livroDAO.obterTodosLivros();
        return livros;
    }
    public Livro getLivro() {
        return livro;
    }
    public Integer getAutorId() {
        return autorId;
    }
    public List<Autor> getAutoresDoLivro(){
        //return livroDAO.obterAutoresDoLivro(livro);
        return livro.getAutores();
    }
    public void setAutorId(Integer autorId) {
        this.autorId = autorId;
    }
    public void setLivro(Livro livro) {
        this.livro = livro;
    }
    public void gravar(){
        System.out.println("Gravando o livro: " + livro.getTitulo());
        if(livro.getAutores().isEmpty()){
            throw new RuntimeException("Livro deve ter ao menos um autor!");
        }
        EntityManager em = new JpaUtil().getEntityManager();
        LivroDAO dao = new LivroDAO(em);
        dao.persist(livro);
        System.out.println("Gravou o livro: " + livro.getTitulo());
        clear();
    }
    public void clear(){
        livro = new Livro();
    }
    public void gravarAutor(){
        Autor autor = autorDAO.obterAutorPorId(autorId);
        livro.addAutor(autor);
        System.out.println("Gravou o autor " + autor.getNome() + " Para o livro: " + livro.getTitulo());
    }
}E meu Model:
package br.com.alura.livraria.model;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@NamedQueries({
    @NamedQuery(name = "obterAutoresDoLivro", query = "select l.autores from Livro l"),
    @NamedQuery(name = "obterTodosLivros", query = "select l from Livro l")
})
@Entity
@SequenceGenerator(name = "SEQ_LIVRO", sequenceName = "SEQ_LIVRO", initialValue = 1, allocationSize = 1)
public class Livro {
    public static final String OBTER_LIVROS_POR_AUTOR = "obterLivrosPorAutor";
    public static final String OBTER_AUTORES_DO_LIVRO = "obterAutoresDoLivro";
    public static final String OBTER_TODOS_LIVROS = "obterTodosLivros";
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_LIVRO")
    private int id;
    private String titulo;
    private String isbn;
    private Double preco;
    @Temporal(TemporalType.DATE)
    private Calendar dataLancamento;
    @ManyToMany
    private List<Autor> autores = new ArrayList<Autor>();
    public void addAutor(Autor autor) {
        this.autores.add(autor);
    }
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public String getTitulo() {
        return titulo;
    }
    public void setTitulo(String titulo) {
        this.titulo = titulo;
    }
    public String getIsbn() {
        return isbn;
    }
    public void setIsbn(String isbn) {
        this.isbn = isbn;
    }
    public Double getPreco() {
        return preco;
    }
    public void setPreco(Double preco) {
        this.preco = preco;
    }
    public Calendar getDataLancamento() {
        return dataLancamento;
    }
    public void setDataLancamento(Calendar dataLancamento) {
        this.dataLancamento = dataLancamento;
    }
    public List<Autor> getAutores() {
        return autores;
    }
    public void setAutores(List<Autor> autores) {
        this.autores = autores;
    }
}Agradeço qualquer ajuda a identificar o que pode estar ocorrendo.
 
            