Estou aprendendo JPA e Hibernate e estou com esse erro e não tenho ideia do que seja.
OBS: Quando tento salvar um objeto através do formulário em JSF, cai em um erro. Mas quando crio uma classe main e tento persistir da certo.
javax.servlet.ServletException: java.lang.ExceptionInInitializerError
javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Root Cause
javax.faces.el.EvaluationException: java.lang.ExceptionInInitializerError
javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:101)
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
javax.faces.component.UICommand.broadcast(UICommand.java:315)
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Root Cause
java.lang.ExceptionInInitializerError
br.com.projetojsf1.dao.DaoGeneric.salvar(DaoGeneric.java:11)
br.com.projetojsf1.bean.PessoaBean.salvar(PessoaBean.java:17)
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.base/java.lang.reflect.Method.invoke(Method.java:568)
org.apache.el.parser.AstValue.invoke(AstValue.java:252)
org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:266)
com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
javax.faces.component.UICommand.broadcast(UICommand.java:315)
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Root Cause
java.lang.ClassCastException: class org.hibernate.ejb.HibernatePersistence cannot be cast to class javax.persistence.spi.PersistenceProvider (org.hibernate.ejb.HibernatePersistence is in unnamed module of loader java.net.URLClassLoader @6ce253f1; javax.persistence.spi.PersistenceProvider is in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @3b0ca5e1)
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:62)
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)
br.com.projetojsf1.util.JPAUtil.verificaConexao(JPAUtil.java:16)
br.com.projetojsf1.util.JPAUtil.<clinit>(JPAUtil.java:12)
br.com.projetojsf1.dao.DaoGeneric.salvar(DaoGeneric.java:11)
br.com.projetojsf1.bean.PessoaBean.salvar(PessoaBean.java:17)
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.base/java.lang.reflect.Method.invoke(Method.java:568)
org.apache.el.parser.AstValue.invoke(AstValue.java:252)
org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:266)
com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
javax.faces.component.UICommand.broadcast(UICommand.java:315)
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Olá, boa noite! Posta o seu arquivo.xhtml e a sua classe Bean que vc usa para persistir os dados.
Olá Carlos, obrigado pela ajuda.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>meuprimeiroProjetojsf</groupId>
<artifactId>meuprimeiroProjetojsf</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>meuprimeiroProjetojsf</name>
<!-- FIXME change it to the project's website -->
<url>http://www.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-entitymanager -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.8.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.8.Final</version>
<scope>compile</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.20</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.sun.faces/jsf-impl -->
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.14</version>
<scope>compile</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.sun.faces/jsf-api -->
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.14</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven
defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Esse arquivo é o pom.xml. Está usando JSF, certo ? Posta seu arquivo.xhtml (arquivo que você usou para criar o formulário) e em seguida a classe bean
que você atribui ao value de seu formulário. Pelo que estou vendo no erro, a classe é PessoaBean
. Posta esses 2 arquivos para eu tentar te ajudar.
página xhtml
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<h:head></h:head>
<body>
<h1>Formulário JSF</h1>
<h:form>
<h:outputLabel value="nome" />
<h:inputText value="#{pessoaBean.pessoa.nome}" />
<br />
<h:outputLabel value="sobrenome" />
<h:inputText value="#{pessoaBean.pessoa.sobrenome}" />
<br />
<h:outputLabel value="idade" />
<h:inputText value="#{pessoaBean.pessoa.idade}" />
<br />
<br />
<h:commandButton action="#{pessoaBean.salvar}" value="Salvar" />
</h:form>
</body>
</html>
Meu Bean
package br.com.projetojsf1.bean;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import br.com.projetojsf1.dao.DaoGeneric;
import br.com.projetojsf1.model.Pessoa;
@ManagedBean(name = "pessoaBean")
@ViewScoped
public class PessoaBean {
private Pessoa pessoa = new Pessoa();
private DaoGeneric<Pessoa> daoGeneric = new DaoGeneric<Pessoa>();
public String salvar() {
daoGeneric.salvar(pessoa);
return "";
}
public Pessoa getPessoa() {
return pessoa;
}
public void setPessoa(Pessoa pessoa) {
this.pessoa = pessoa;
}
public DaoGeneric<Pessoa> getDaoGeneric() {
return daoGeneric;
}
public void setDaoGeneric(DaoGeneric<Pessoa> daoGeneric) {
this.daoGeneric = daoGeneric;
}
}
Agora eu mexendo pra ver se resolvia algo, estou com esse erro
error
abr. 02, 2022 10:21:57 PM com.sun.faces.lifecycle.InvokeApplicationPhase execute
WARNING: #{pessoaBean.salvar}: java.lang.ExceptionInInitializerError
javax.faces.FacesException: #{pessoaBean.salvar}: java.lang.ExceptionInInitializerError
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:540)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:687)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:382)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:895)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1732)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: javax.faces.el.EvaluationException: java.lang.ExceptionInInitializerError
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:101)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
... 29 more
Caused by: java.lang.ExceptionInInitializerError
at br.com.projetojsf1.dao.DaoGeneric.salvar(DaoGeneric.java:11)
at br.com.projetojsf1.bean.PessoaBean.salvar(PessoaBean.java:17)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.apache.el.parser.AstValue.invoke(AstValue.java:252)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:266)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
... 30 more
Caused by: java.lang.ClassCastException: class org.hibernate.ejb.HibernatePersistence cannot be cast to class javax.persistence.spi.PersistenceProvider (org.hibernate.ejb.HibernatePersistence is in unnamed module of loader java.net.URLClassLoader @6ce253f1; javax.persistence.spi.PersistenceProvider is in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @7c65786b)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:62)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)
at br.com.projetojsf1.util.JPAUtil.verificaConexao(JPAUtil.java:16)
at br.com.projetojsf1.util.JPAUtil.<clinit>(JPAUtil.java:12)
... 40 more
abr. 02, 2022 10:21:57 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [Faces Servlet] in context with path [/meuprimeiroProjetojsf] threw exception [java.lang.ExceptionInInitializerError] with root cause
java.lang.ClassCastException: class org.hibernate.ejb.HibernatePersistence cannot be cast to class javax.persistence.spi.PersistenceProvider (org.hibernate.ejb.HibernatePersistence is in unnamed module of loader java.net.URLClassLoader @6ce253f1; javax.persistence.spi.PersistenceProvider is in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @7c65786b)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:62)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)
at br.com.projetojsf1.util.JPAUtil.verificaConexao(JPAUtil.java:16)
at br.com.projetojsf1.util.JPAUtil.<clinit>(JPAUtil.java:12)
at br.com.projetojsf1.dao.DaoGeneric.salvar(DaoGeneric.java:11)
at br.com.projetojsf1.bean.PessoaBean.salvar(PessoaBean.java:17)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.apache.el.parser.AstValue.invoke(AstValue.java:252)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:266)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:540)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:687)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:382)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:895)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1732)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:833)
abr. 02, 2022 10:24:14 PM org.apache.catalina.core.StandardContext reload
INFO: Reloading Context with name [/meuprimeiroProjetojsf] has started
abr. 02, 2022 10:24:14 PM org.apache.catalina.session.StandardSession doWriteObject
WARNING: Cannot serialize session attribute [com.sun.faces.application.view.activeViewMaps] for session [A836A07667D62DBA937CD1F65F33D099]
java.io.NotSerializableException: br.com.projetojsf1.bean.PessoaBean
at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1197)
at java.base/java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:354)
at java.base/java.util.HashMap.internalWriteEntries(HashMap.java:1944)
at java.base/java.util.HashMap.writeObject(HashMap.java:1497)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at java.base/java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1201)
at java.base/java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1526)
at java.base/java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1448)
at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1191)
at java.base/java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:354)
at java.base/java.util.LinkedHashMap.internalWriteEntries(LinkedHashMap.java:334)
at java.base/java.util.HashMap.writeObject(HashMap.java:1497)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at java.base/java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1201)
at java.base/java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1526)
at java.base/java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1448)
at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1191)
at java.base/java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:354)
at org.apache.catalina.session.StandardSession.doWriteObject(StandardSession.java:1726)
at org.apache.catalina.session.StandardSession.writeObjectData(StandardSession.java:1067)
at org.apache.catalina.session.StandardManager.doUnload(StandardManager.java:317)
at org.apache.catalina.session.StandardManager.unload(StandardManager.java:268)
at org.apache.catalina.session.StandardManager.stopInternal(StandardManager.java:384)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5473)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257)
at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3811)
at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:311)
at org.apache.catalina.core.StandardContext.backgroundProcess(StandardContext.java:5613)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1365)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1369)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1369)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1347)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:833)
O formulário está sendo carregado normalmente no navegador ? Me parece que está tendo um conflito de dependências. Tente remover o hibernate-entitymanager
e deixe apenas o hibernate-core
.
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.8.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.8.Final</version>
<scope>compile</scope>
</dependency>
Outra coisa, no seu Bean, faltou você implementar Serializable
. Modifique o seguinte trecho em seu Bean. public class PessoaBean implements Serializable
.
Olá, eu consegui resolver, o problema era que o maven o meu projeto não estava encontrando o hibernate core, adicionei na lib e depois adicionei no BuildPath, ai deu certo, obrigado
1 curtida
Se vc está usando maven, essa forma como vc resolveu não é certo. Melhor investigar pq o maven não conseguiu baixar a dependência.
Obrigado pela dica e pensei na mesma forma, o que eu fiz foi o seguinte, fui na configuração do projeto/ Web Deployment Assembly e lá adicionei o Maven Dependencies, ai deu tudo certo
1 curtida