Solucionado (ver solução)
Solucionado
(ver solução)
4
respostas

Não cria Tabela

To usando o jdk 11.0.2

o projeto no git: https://github.com/MelchiorFelix/CursoMVC1Alura/tree/master/casadocodigo

Esse erro que ta dando no console :

mar 26, 2019 9:49:17 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version name:   Apache Tomcat/9.0.16
mar 26, 2019 9:49:17 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built:          Feb 4 2019 16:30:29 UTC
mar 26, 2019 9:49:17 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version number: 9.0.16.0
mar 26, 2019 9:49:17 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name:               Windows 10
mar 26, 2019 9:49:17 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version:            10.0
mar 26, 2019 9:49:17 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture:          amd64
mar 26, 2019 9:49:17 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home:             C:\Program Files\Java\jdk-11.0.2
mar 26, 2019 9:49:17 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version:           11.0.2+9-LTS
mar 26, 2019 9:49:17 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor:            Oracle Corporation
mar 26, 2019 9:49:17 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE:         C:\Users\melch\eclipse-workspace-AlurasAlura\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
mar 26, 2019 9:49:17 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME:         C:\apache-tomcat-9.0.16
mar 26, 2019 9:49:17 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=C:\Users\melch\eclipse-workspace-AlurasAlura\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
mar 26, 2019 9:49:17 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=C:\apache-tomcat-9.0.16
mar 26, 2019 9:49:17 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=C:\Users\melch\eclipse-workspace-AlurasAlura\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
mar 26, 2019 9:49:17 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=Cp1252
4 respostas
mar 26, 2019 9:49:17 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: Loaded APR based Apache Tomcat Native library [1.2.21] using APR version [1.6.5].
mar 26, 2019 9:49:17 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
mar 26, 2019 9:49:17 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
mar 26, 2019 9:49:17 AM org.apache.catalina.core.AprLifecycleListener initializeSSL
INFO: OpenSSL successfully initialized [OpenSSL 1.1.1a  20 Nov 2018]
mar 26, 2019 9:49:17 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
mar 26, 2019 9:49:17 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-nio-8009"]
mar 26, 2019 9:49:17 AM org.apache.catalina.startup.Catalina load
INFO: Server initialization in [640] milliseconds
mar 26, 2019 9:49:17 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service [Catalina]
mar 26, 2019 9:49:17 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet engine: [Apache Tomcat/9.0.16]
mar 26, 2019 9:49:17 AM org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
WARNING: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [116] milliseconds.
mar 26, 2019 9:49:18 AM org.apache.catalina.core.ApplicationContext log
INFO: Spring WebApplicationInitializers detected on classpath: [br.com.alura.loja.conf.ServeletSpringMVC@194b9783]
log4j:WARN No appenders could be found for logger (br.com.alura.loja.conf.ServeletSpringMVC).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
mar 26, 2019 9:49:19 AM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
mar 26, 2019 9:49:19 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'dispatcher'
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$2 (file:/C:/Users/melch/eclipse-workspace-AlurasAlura/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/casadocodigo/WEB-INF/lib/spring-core-4.1.0.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
mar 26, 2019 9:49:23 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
mar 26, 2019 9:49:23 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8009"]
mar 26, 2019 9:49:23 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in [6.038] milliseconds

Tenta colocar toda a mensagem do console, nessa parte que postou não tem ERRO, tem apenas INFO e WARNING

Esse erro e quando tento cadastrar o produto

Root Cause

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'casadocodigo.produto' doesn't exist

e no console

Produto [titulo=JAVA 5, discricao=gfdgdfg, paginas=15]
Hibernate: insert into Produto (discricao, paginas, titulo) values (?, ?, ?)
mar 26, 2019 10:29:03 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/casadocodigo] threw exception [Request processing failed; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute statement] with root cause
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'casadocodigo.produto' doesn't exist
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
    at com.mysql.jdbc.Util.getInstance(Util.java:382)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3603)
solução!

vamos lá,depois de uma longa busca pela internet resolvi de uma seguinte forma:

DriverManagerDataSource dataSource = new DriverManagerDataSource();
        dataSource.setUsername("root");
        dataSource.setPassword("12345");
        dataSource.setUrl("jdbc:mysql://localhost/casadocodigo?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC");
        dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
        factoryBean.setDataSource(dataSource);

Lembrando que estou utilizando o mysql na versão 8.0.15,além disso mudei a depency para

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>8.0.15</version>
    </dependency>