ta acontecendo o seguinte:
nao grava autor, da erro de javax. persistence.PersistenceException; na video aula ele nao ensina a mexer com mysql mostra so logando o mysql e cadastrando no modulo 4 nao aparece o nome dos autores cadastraddos
ta acontecendo o seguinte:
nao grava autor, da erro de javax. persistence.PersistenceException; na video aula ele nao ensina a mexer com mysql mostra so logando o mysql e cadastrando no modulo 4 nao aparece o nome dos autores cadastraddos
Olá, no início de cada capítuli geralmente tem um botal (abaixo do video) escrito VER TEXTO. nessa parte tem o link para baixar o projeto, Feito isso, vc precisa ter o mysql baixado e instalado. Lembre-se de q se você tiver uma senha no usuario root no mysql vc precisa setar ela no arquivo PERSISTENce.xml dentro do projeto. Outra coisa, vc deve criar o database para q o hibernate ache-o. o Comando para criar um database é CREATE DATABASE NOME; O resto o hibernate faz.
importei o projeto sim aquele workbenck faz, se num me engano o mysql ta instaldo so que nao foi feito pelo hibernate nao....
mas e ai? deu certo? O workbench é um software que permite gerenciar seu database de forma gráfica(entre outras coisas)... O hibernate vai procurar sempre pelo database que estiver no Persistence.xml e só irá conseguir fazer as coisas se o usuário e senha estiverem setados.
tinha q mostra a instalacao como configura do zero o mysql ou outro banco. nao deu certo raphael
nao deu certo raphael
Jul 28, 2014 10:47:56 AM org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
Jul 28, 2014 10:47:56 AM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.1.8.Final}
Jul 28, 2014 10:47:56 AM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
Jul 28, 2014 10:47:56 AM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Jul 28, 2014 10:47:58 AM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000402: Using Hibernate built-in connection pool (not for production use!)
Jul 28, 2014 10:47:58 AM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000115: Hibernate connection pool size: 20
Jul 28, 2014 10:47:58 AM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000006: Autocommit mode: true
Jul 28, 2014 10:47:58 AM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000401: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql://localhost/livrariadb]
Jul 28, 2014 10:47:58 AM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000046: Connection properties: {user=root, autocommit=true, release_mode=auto}
Jul 28, 2014 10:47:59 AM org.hibernate.engine.jdbc.internal.JdbcServicesImpl configure
WARN: HHH000342: Could not obtain connection to query metadata : Access denied for user 'root'@'localhost' (using password: NO)
Jul 28, 2014 10:47:59 AM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
Jul 28, 2014 10:47:59 AM org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation
INFO: HHH000422: Disabling contextual LOB creation as connection was null
Jul 28, 2014 10:47:59 AM org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
INFO: HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory
Jul 28, 2014 10:47:59 AM org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
Jul 28, 2014 10:47:59 AM org.hibernate.validator.internal.util.Version <clinit>
INFO: HV000001: Hibernate Validator 4.3.0.Final
Jul 28, 2014 10:48:00 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: HHH000228: Running hbm2ddl schema update
Jul 28, 2014 10:48:00 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: HHH000102: Fetching database metadata
Jul 28, 2014 10:48:01 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
ERROR: HHH000319: Could not get database metadata
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4096)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4028)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:919)
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1694)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1244)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2412)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2445)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2230)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:813)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:399)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:334)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(DriverManagerConnectionProviderImpl.java:193)
at org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.prepare(SuppliedConnectionProviderConnectionHelper.java:51)
at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:194)
at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:178)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:503)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1750)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:94)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)
at br.com.caelum.livraria.dao.JPAUtil.<clinit>(JPAUtil.java:10)
at br.com.caelum.livraria.dao.PopulaBanco.main(PopulaBanco.java:17)
Jul 28, 2014 10:48:01 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
ERROR: HHH000299: Could not complete schema update
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4096)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4028)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:919)
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1694)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1244)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2412)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2445)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2230)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:813)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:399)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:334)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(DriverManagerConnectionProviderImpl.java:193)
at org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.prepare(SuppliedConnectionProviderConnectionHelper.java:51)
at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:194)
at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:178)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:503)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1750)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:94)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)
at br.com.caelum.livraria.dao.JPAUtil.<clinit>(JPAUtil.java:10)
at br.com.caelum.livraria.dao.PopulaBanco.main(PopulaBanco.java:17)
Jul 28, 2014 10:48:01 AM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
WARN: SQL Error: 1045, SQLState: 28000
Jul 28, 2014 10:48:01 AM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
ERROR: Access denied for user 'root'@'localhost' (using password: NO)
Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Could not open connection
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1377)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1300)
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:1387)
at org.hibernate.ejb.TransactionImpl.begin(TransactionImpl.java:62)
at br.com.caelum.livraria.dao.PopulaBanco.main(PopulaBanco.java:19)
Caused by: org.hibernate.exception.GenericJDBCException: Could not open connection
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:304)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.getConnection(LogicalConnectionImpl.java:169)
at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doBegin(JdbcTransaction.java:67)
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.begin(AbstractTransactionImpl.java:160)
at org.hibernate.internal.SessionImpl.beginTransaction(SessionImpl.java:1395)
at org.hibernate.ejb.TransactionImpl.begin(TransactionImpl.java:59)
... 1 more
Caused by: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4096)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4028)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:919)
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1694)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1244)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2412)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2445)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2230)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:813)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:399)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:334)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(DriverManagerConnectionProviderImpl.java:193)
at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:292)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:297)
... 6 more
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(); private Integer autorId;
public Integer getAutorId() { return autorId; }
public void setAutorId(Integer autorId) { this.autorId = autorId; }
public Livro getLivro() { return livro; } public void gravarAutor(){ Autor autor = new DAO(Autor.class).buscaPorId(this.autorId); this.livro.adicionaAutor(autor); }
public List getAutores(){ return new DAO(Autor.class).listaTodos(); }
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.class).adiciona(this.livro); }
}
Oi Gustavo,
Voce está com um problema no jpa/mysql. O mysql exige um login/senha diferente do que está no arquivo persistence.xml. Verifique a configuração nesse arquivo.
Se tiver com muitas dúvidas sobre JPA aconselho assistir este treinamento antes.
Abs
ja fiz isso... agora ta dando outro erro na hora de fazer aquele metodo gravaAutor o erro ta dando no buscaporId dei ctrl 1 mas ta querendo em fazer um change method, change type rename e outras coisa mas nao igual do video
então o problema do persistence.xml vc já arrumou? sobre esse outro erro, geralmente o eclipse sugere 'change method' quando, por algum motivo, o método não é encontrado. Você verificou digitou tudo corretamente? verifique a assinatura do método (nome e parâmetros) e verifique se está batendo com o nome utilizado na chamada do método. Seria bom também colar aqui a mensagem que o Eclipse está dando em relação ao erro. O change method é uma sugestão apenas, e não um erro
public Livro getLivro() { return livro; } public void gravarAutor(){ Autor autor = new DAO(Autor.class).buscaPorId(this.autorId); this.livro.adicionaAutor(autor); } o metodo eh esse acima o erro eh esse:
buscaPorId
esse ai não é o erro, e apenas o nome de um método. O erro você pode ver posicionando o mouse em cima de onde ele está (o eclipse sublinha as linhas com erro, coloque o mouse em cima e uma mensagem com o problema aparecerá, cole ela aqui para tentarmos ajudar)
meu querido o erro ta dando dentro desse metodo. e essa buscaPorId ta sublinhado no eclipse
Oi Gustavo.
Coloca o mouse em cima do método que está sublinhado com vermelho e ve qual mensagem aparece. Ou clica no x vermelho no canto da linha onde ta o buscaPorId.
"meu querido" ? não sei o que quis dizer com isso, se foi irônico ou não, mas enfim, estou me retirando, flw.
Gustavo, o problema foi resolvido? abs
nao.ao ao clicar sobre o buscaPorId da a seguinte msg: o method buscaPorId(long) in the type DAO is not applicable argument (integer)
Oi Gustavo,
o método buscaPorId
recebe um número do tipo Long
. Ao chamar o método vc passou um número do tipo Integer
, incompatível com o tipo Long
. Por isso o seu código não compila. Tente chamar o método buscaPorId
de seguinte maneira:
public void gravarAutor() {
Autor autor = new DAO(Autor.class).buscaPorId(this.autorId.longValue());
this.livro.adicionaAutor(autor);
}
Repare o this.autorId.longValue()
.
Me fale, por favor, se resolveu o problema.
Abs
Gustavo, faz diferente e mais fácil. Invés de alterar o método gravarAutor
altere o método DAO. Abra a classe DAO
e procure o método buscaPorId
. Nele altere o tipo do parâmetro de Long
para Integer
:
public T buscaPorId(Integer id) { //aqui é a alteração, era Long
EntityManager em = new JPAUtil().getEntityManager();
T instancia = em.find(classe, id);
em.close();
return instancia;
}
De qq forma, me fale o que vc fez e se funcionou (ou não).
abs
this.livro.adicionaAutor(autor); ta dando erro o parametro autor e a msg q aparece no eclipse eh: create local variable autor createfield autor create constant autor change to autorid rename in file (ctrl +2 r)
Gustavo, o outro problema então foi resolvido? Como resolveu?
Nico, agora na class livro.xhtml esta errada aqui:
so a parte do livroBean.gravar. essa parte da sublinhada com erro..
Se na classe LivroBean
realmente existe o método gravar()
vale a pena testar a aplicação. Ou seja, iniciar o Tomcat e acessar a aplicação pelo navegador.
O validador de páginas xhtml do Eclipse nem sempre funciona corretamente e acusa problemas que na verdade não existem.
Vc já testou aplicação pelo navegador?
abs
pois eh, fui testa. e ao clicar sobre gravar autor deu o seguinte erro: A exibição de /livro.xhtml não pôde ser restaurada
Para desabilitar a validação mais rígida das arquivos xhtml
do Eclipse segue os passos seguintes
No Menu Preferences
-> Item Validation
:
Tire:
1) Facelet HTML Validator
2) JSF View Application Configuration Validator
3) JSF View Validator
Isto é preciso pois o Eclipse quer que todos os métodos associados com o atributo action do componente h:commandButton
devolvem obrigatoriamente um String
(que não é preciso).
Se vc recebe aquele erro que a view não pode ser restaurada, basta recarregar a página. No entanto, NÃO aperte F5, envie uma nova requisição para recriar a pagina completa.
agora ta dando esse erro nico... ago 01, 2014 5:29:42 PM org.apache.catalina.core.AprLifecycleListener init INFORMAÇÕES: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre8\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre8/bin/client;C:/Program Files/Java/jre8/bin;C:/Program Files/Java/jre8/lib/i386;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Java\jdk1.8.0_11\bin;C:\Program Files\MySQL\MySQL Utilities 1.4.3\;C:\Program Files\MySQL\MySQL Utilities 1.4.3\Doctrine extensions for PHP\;C:\eclipse;;. ago 01, 2014 5:29:43 PM org.apache.tomcat.util.digester.SetPropertiesRule begin ADVERTÊNCIA: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:livraria' did not find a matching property. ago 01, 2014 5:29:44 PM org.apache.coyote.AbstractProtocol init INFORMAÇÕES: Initializing ProtocolHandler ["http-bio-8080"] ago 01, 2014 5:29:44 PM org.apache.coyote.AbstractProtocol init INFORMAÇÕES: Initializing ProtocolHandler ["ajp-bio-8009"] ago 01, 2014 5:29:44 PM org.apache.catalina.startup.Catalina load INFORMAÇÕES: Initialization processed in 2204 ms ago 01, 2014 5:29:44 PM org.apache.catalina.core.StandardService startInternal INFORMAÇÕES: Starting service Catalina ago 01, 2014 5:29:44 PM org.apache.catalina.core.StandardEngine startInternal INFORMAÇÕES: Starting Servlet Engine: Apache Tomcat/7.0.55 ago 01, 2014 5:29:49 PM com.sun.faces.config.ConfigureListener contextInitialized INFORMAÇÕES: Inicializando Mojarra 2.1.14 ( 20121023-1153) para o contexto '/livraria' ago 01, 2014 5:29:50 PM com.sun.faces.spi.InjectionProviderFactory createInstance INFORMAÇÕES: JSF1048: Anotações PostConstruct/PreDestroy presentes. Os métodos ManagedBeans marcados com essas anotações informarão as anotações processadas. ago 01, 2014 5:29:50 PM org.hibernate.validator.internal.util.Version INFO: HV000001: Hibernate Validator 4.3.0.Final ago 01, 2014 5:29:51 PM org.apache.catalina.session.StandardManager doLoad GRAVE: IOException while loading persisted sessions: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: br.com.caelum.livraria.bean.LivroBean java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: br.com.caelum.livraria.bean.LivroBean at java.io.ObjectInputStream.readObject0(Unknown Source) at java.io.ObjectInputStream.readObject(Unknown Source) at java.util.HashMap.readObject(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at java.io.ObjectStreamClass.invokeReadObject(Unknown Source) at java.io.ObjectInputStream.readSerialData(Unknown Source) at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source) at java.io.ObjectInputStream.readObject0(Unknown Source) at java.io.ObjectInputStream.defaultReadFields(Unknown Source) at java.io.ObjectInputStream.readSerialData(Unknown Source) at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source) at java.io.ObjectInputStream.readObject0(Unknown Source) at java.io.ObjectInputStream.readArray(Unknown Source) at java.io.ObjectInputStream.readObject0(Unknown Source) at java.io.ObjectInputStream.readObject(Unknown Source) at java.util.HashMap.readObject(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at java.io.ObjectStreamClass.invokeReadObject(Unknown Source) at java.io.ObjectInputStream.readSerialData(Unknown Source) at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source) at java.io.ObjectInputStream.readObject0(Unknown Source) at java.io.ObjectInputStream.readArray(Unknown Source) at java.io.ObjectInputStream.readObject0(Unknown Source) at java.io.ObjectInputStream.readObject(Unknown Source) at java.util.HashMap.readObject(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at java.io.ObjectStreamClass.invokeReadObject(Unknown Source) at java.io.ObjectInputStream.readSerialData(Unknown Source) at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source) at java.io.ObjectInputStream.readObject0(Unknown Source) at java.io.ObjectInputStream.readObject(Unknown Source) at java.util.HashMap.readObject(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at java.io.ObjectStreamClass.invokeReadObject(Unknown Source) at java.io.ObjectInputStream.readSerialData(Unknown Source) at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source) at java.io.ObjectInputStream.readObject0(Unknown Source) at java.io.ObjectInputStream.readObject(Unknown Source) at org.apache.catalina.session.StandardSession.readObject(StandardSession.java:1619) at org.apache.catalina.session.StandardSession.readObjectData(StandardSession.java:1084) at org.apache.catalina.session.StandardManager.doLoad(StandardManager.java:282) at org.apache.catalina.session.StandardManager.load(StandardManager.java:202) at org.apache.catalina.session.StandardManager.startInternal(StandardManager.java:489) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5499) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.io.NotSerializableException: br.com.caelum.livraria.bean.LivroBean at java.io.ObjectOutputStream.writeObject0(Unknown Source) at java.io.ObjectOutputStream.writeObject(Unknown Source) at java.util.HashMap.internalWriteEntries(Unknown Source) at java.util.HashMap.writeObject(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source) at java.io.ObjectOutputStream.writeSerialData(Unknown Source) at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source) at java.io.ObjectOutputStream.writeObject0(Unknown Source) at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source) at java.io.ObjectOutputStream.writeSerialData(Unknown Source) at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source) at java.io.ObjectOutputStream.writeObject0(Unknown Source) at java.io.ObjectOutputStream.writeArray(Unknown Source) at java.io.ObjectOutputStream.writeObject0(Unknown Source) at java.io.ObjectOutputStream.writeObject(Unknown Source) at java.util.HashMap.internalWriteEntries(Unknown Source) at java.util.HashMap.writeObject(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source) at java.io.ObjectOutputStream.writeSerialData(Unknown Source) at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source) at java.io.ObjectOutputStream.writeObject0(Unknown Source) at java.io.ObjectOutputStream.writeArray(Unknown Source) at java.io.ObjectOutputStream.writeObject0(Unknown Source) at java.io.ObjectOutputStream.writeObject(Unknown Source) at java.util.LinkedHashMap.internalWriteEntries(Unknown Source) at java.util.HashMap.writeObject(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source) at java.io.ObjectOutputStream.writeSerialData(Unknown Source) at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source) at java.io.ObjectOutputStream.writeObject0(Unknown Source) at java.io.ObjectOutputStream.writeObject(Unknown Source) at java.util.LinkedHashMap.internalWriteEntries(Unknown Source) at java.util.HashMap.writeObject(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source) at java.io.ObjectOutputStream.writeSerialData(Unknown Source) at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source) at java.io.ObjectOutputStream.writeObject0(Unknown Source) at java.io.ObjectOutputStream.writeObject(Unknown Source) at org.apache.catalina.session.StandardSession.writeObject(StandardSession.java:1695) at org.apache.catalina.session.StandardSession.writeObjectData(StandardSession.java:1101) at org.apache.catalina.session.StandardManager.doUnload(StandardManager.java:430) at org.apache.catalina.session.StandardManager.unload(StandardManager.java:351) at org.apache.catalina.session.StandardManager.stopInternal(StandardManager.java:516) at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232) at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5681) at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232) at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1591) at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1580) ... 4 more
ago 01, 2014 5:29:51 PM org.apache.catalina.session.StandardManager startInternal GRAVE: Exception loading sessions from persistent storage java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: br.com.caelum.livraria.bean.LivroBean at java.io.ObjectInputStream.readObject0(Unknown Source) at java.io.ObjectInputStream.readObject(Unknown Source) at java.util.HashMap.readObject(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at java.io.ObjectStreamClass.invokeReadObject(Unknown Source) at java.io.ObjectInputStream.readSerialData(Unknown Source) at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source) at java.io.ObjectInputStream.readObject0(Unknown Source) at java.io.ObjectInputStream.defaultReadFields(Unknown Source) at java.io.ObjectInputStream.readSerialData(Unknown Source) at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source) at java.io.ObjectInputStream.readObject0(Unknown Source) at java.io.ObjectInputStream.readArray(Unknown Source) at java.io.ObjectInputStream.readObject0(Unknown Source) at java.io.ObjectInputStream.readObject(Unknown Source) at java.util.HashMap.readObject(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at java.io.ObjectStreamClass.invokeReadObject(Unknown Source) at java.io.ObjectInputStream.readSerialData(Unknown Source) at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source) at java.io.ObjectInputStream.readObject0(Unknown Source) at java.io.ObjectInputStream.readArray(Unknown Source) at java.io.ObjectInputStream.readObject0(Unknown Source) at java.io.ObjectInputStream.readObject(Unknown Source) at java.util.HashMap.readObject(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at java.io.ObjectStreamClass.invokeReadObject(Unknown Source) at java.io.ObjectInputStream.readSerialData(Unknown Source) at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source) at java.io.ObjectInputStream.readObject0(Unknown Source) at java.io.ObjectInputStream.readObject(Unknown Source) at java.util.HashMap.readObject(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at java.io.ObjectStreamClass.invokeReadObject(Unknown Source) at java.io.ObjectInputStream.readSerialData(Unknown Source) at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source) at java.io.ObjectInputStream.readObject0(Unknown Source) at java.io.ObjectInputStream.readObject(Unknown Source) at org.apache.catalina.session.StandardSession.readObject(StandardSession.java:1619) at org.apache.catalina.session.StandardSession.readObjectData(StandardSession.java:1084) at org.apache.catalina.session.StandardManager.doLoad(StandardManager.java:282) at org.apache.catalina.session.StandardManager.load(StandardManager.java:202) at org.apache.catalina.session.StandardManager.startInternal(StandardManager.java:489) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5499) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.io.NotSerializableException: br.com.caelum.livraria.bean.LivroBean at java.io.ObjectOutputStream.writeObject0(Unknown Source) at java.io.ObjectOutputStream.writeObject(Unknown Source) at java.util.HashMap.internalWriteEntries(Unknown Source) at java.util.HashMap.writeObject(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source) at java.io.ObjectOutputStream.writeSerialData(Unknown Source) at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source) at java.io.ObjectOutputStream.writeObject0(Unknown Source) at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source) at java.io.ObjectOutputStream.writeSerialData(Unknown Source) at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source) at java.io.ObjectOutputStream.writeObject0(Unknown Source) at java.io.ObjectOutputStream.writeArray(Unknown Source) at java.io.ObjectOutputStream.writeObject0(Unknown Source) at java.io.ObjectOutputStream.writeObject(Unknown Source) at java.util.HashMap.internalWriteEntries(Unknown Source) at java.util.HashMap.writeObject(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source) at java.io.ObjectOutputStream.writeSerialData(Unknown Source) at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source) at java.io.ObjectOutputStream.writeObject0(Unknown Source) at java.io.ObjectOutputStream.writeArray(Unknown Source) at java.io.ObjectOutputStream.writeObject0(Unknown Source) at java.io.ObjectOutputStream.writeObject(Unknown Source) at java.util.LinkedHashMap.internalWriteEntries(Unknown Source) at java.util.HashMap.writeObject(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source) at java.io.ObjectOutputStream.writeSerialData(Unknown Source) at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source) at java.io.ObjectOutputStream.writeObject0(Unknown Source) at java.io.ObjectOutputStream.writeObject(Unknown Source) at java.util.LinkedHashMap.internalWriteEntries(Unknown Source) at java.util.HashMap.writeObject(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source) at java.io.ObjectOutputStream.writeSerialData(Unknown Source) at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source) at java.io.ObjectOutputStream.writeObject0(Unknown Source) at java.io.ObjectOutputStream.writeObject(Unknown Source) at org.apache.catalina.session.StandardSession.writeObject(StandardSession.java:1695) at org.apache.catalina.session.StandardSession.writeObjectData(StandardSession.java:1101) at org.apache.catalina.session.StandardManager.doUnload(StandardManager.java:430) at org.apache.catalina.session.StandardManager.unload(StandardManager.java:351) at org.apache.catalina.session.StandardManager.stopInternal(StandardManager.java:516) at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232) at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5681) at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232) at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1591) at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1580) ... 4 more
ago 01, 2014 5:29:51 PM org.apache.coyote.AbstractProtocol start INFORMAÇÕES: Starting ProtocolHandler ["http-bio-8080"] ago 01, 2014 5:29:51 PM org.apache.coyote.AbstractProtocol start INFORMAÇÕES: Starting ProtocolHandler ["ajp-bio-8009"] ago 01, 2014 5:29:51 PM org.apache.catalina.startup.Catalina start INFORMAÇÕES: Server startup in 7286 ms ago 01, 2014 5:30:15 PM org.apache.catalina.core.StandardWrapperValve invoke GRAVE: Servlet.service() for servlet [Faces Servlet] in context with path [/livraria] threw exception [viewId:/livro.xhtml - A exibição de /livro.xhtml não pôde ser restaurada.] with root cause javax.faces.application.ViewExpiredException: viewId:/livro.xhtml - A exibição de /livro.xhtml não pôde ser restaurada. at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:205) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Unknown Source)
Esse erro é relacionado com o @ViewScope
mas não deve interferir na aplicação, a aplicação deve funcionar normal. Mesmo assim, para evitar essa exceção, coloque a interface Serializable
na classe LivroBean
:
...
public class LivroBean implements java.io.Serializable {
...
Gustavo, que tal fechar essa discussão e abrir uma nova, pois não tem nada a ver com o problema inicial?