4
respostas

Erro no arquivo form.jsp

No Eclipse o arquivo form.jsp apresenta um erro na linha

Abaixo segue algumas exceções q aparece ao executar o Tomcat

[localhost-startStop-1] WARN org.springframework.web.context.support.AnnotationConfigWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'getEntityManagerFactory' defined in class path resource [br/com/caelum/JpaConfigurator.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.exception.GenericJDBCException: Unable to open JDBC Connection for DDL execution
[localhost-startStop-1] ERROR org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'getEntityManagerFactory' defined in class path resource [br/com/caelum/JpaConfigurator.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.exception.GenericJDBCException: Unable to open JDBC Connection for DDL execution

Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.exception.GenericJDBCException: Unable to open JDBC Connection for DDL execution
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:402)

Caused by: org.hibernate.exception.GenericJDBCException: Unable to open JDBC Connection for DDL execution
    at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47)

Caused by: java.sql.SQLException: The server time zone value 'Hora Padr?o Brasil Central' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)

Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value 'Hora Padr?o Brasil Central' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

jul. 27, 2020 12:21:12 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class [org.springframework.web.context.ContextLoaderListener]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'getEntityManagerFactory' defined in class path resource [br/com/caelum/JpaConfigurator.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.exception.GenericJDBCException: Unable to open JDBC Connection for DDL execution
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1762)

Utilizei o mesmo código do professor de JPA, mas msm assim não deu certo.

Alguém pode me ajudar?

4 respostas

Oi EDUARDO

É um problema no timezone do banco. Muda url de conexão do mysql

de:

jdbc:mysql://localhost/contas

para:

jdbc:mysql://localhost/contas?useTimezone=true&serverTimezone=UTC

Olá Otávio!

Continua dando o mesmo problema.

Troquei no JPAConfigurator para dataSource.setUrl("jdbc:mysql://localhost/alura_jpa2?useTimezone=true&serverTimezone=UTC"); e também coloquei do jeito q vc escreveu como contas, ao invés d alura_jpa2, mas não deu certo...

Tem outro palpite?

Estranho Edu, era para resolver.

Tenta atualizar o driver do mysql-connector-java para a versão 5.1.49. Você está tentando se conectar no MySQL 5 ou 8?

Então Otávio, é q eu sou iniciante. Eu nunca mexi com essa parte. Reparei q esses warn e error sempre estão aparecendo, inclusive para um outro projeto q tentei começar para testar. Será q ajuda para alguma coisa??

log4j:WARN No appenders could be found for logger (org.jboss.logging).
log4j:WARN Please initialize the log4j system properly.
Hibernate: alter table Produto drop foreign key FKbsrs2q7ixb8srg7d0nfys9s5e
[localhost-startStop-1] WARN org.springframework.web.context.support.AnnotationConfigWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'getEntityManagerFactory' defined in class path resource [br/com/caelum/JpaConfigurator.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.exception.GenericJDBCException: Unable to open JDBC Connection for DDL execution
[localhost-startStop-1] ERROR org.springframework.web.context.ContextLoader - Context initialization failed

Estou começando a achar q tá faltando algo para instalar, apesar do professor não citar na aula.

Eu estou tentando acessar com o MySQL 8. A versão do driver eu não tõ encontrando

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software