5
respostas

HTTP Status 404 - /projeto-jpa-2

Apr 30, 2020 7:43:51 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:projeto-jpa-2' did not find a matching property.
Apr 30, 2020 7:43:51 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version:        Apache Tomcat/8.0.36
Apr 30, 2020 7:43:51 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built:          Jun 9 2016 13:55:50 UTC
Apr 30, 2020 7:43:51 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number:         8.0.36.0
Apr 30, 2020 7:43:51 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name:               Windows 10
Apr 30, 2020 7:43:51 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version:            10.0
Apr 30, 2020 7:43:51 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture:          amd64
Apr 30, 2020 7:43:51 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home:             C:\Program Files\Java\jre1.8.0_241
5 respostas
Apr 30, 2020 7:43:51 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version:           1.8.0_241-b07
Apr 30, 2020 7:43:51 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor:            Oracle Corporation
Apr 30, 2020 7:43:51 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE:         E:\OneDrive\Projeto_java\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
Apr 30, 2020 7:43:51 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME:         C:\apache-tomcat-8.5.54-windows-x64\apache-tomcat-8.5.54
Apr 30, 2020 7:43:51 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=E:\OneDrive\Projeto_java\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
Apr 30, 2020 7:43:51 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=C:\apache-tomcat-8.5.54-windows-x64\apache-tomcat-8.5.54
Apr 30, 2020 7:43:51 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=E:\OneDrive\Projeto_java\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
Apr 30, 2020 7:43:51 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=C:\apache-tomcat-8.5.54-windows-x64\apache-tomcat-8.5.54\endorsed
Apr 30, 2020 7:43:51 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=Cp1252
Apr 30, 2020 7:43:51 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: 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\jre1.8.0_241\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre1.8.0_241/bin/server;C:/Program Files/Java/jre1.8.0_241/bin;C:/Program Files/Java/jre1.8.0_241/lib/amd64;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\xampp\php;C:\ProgramData\ComposerSetup\bin;C:\Program Files\Dart\dart-sdk\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\Java\jdk1.8.0_241\bin;C:\Program Files\MySQL\MySQL Shell 8.0\bin\;C:\Users\Marcelo\AppData\Local\Microsoft\WindowsApps;C:\Users\Marcelo\AppData\Roaming\Composer\vendor\bin;C:\src\flutter\bin;C:\Users\Marcelo\AppData\Local\Programs\Microsoft VS Code\bin;C:\Program Files\Android\Android Studio\jre\bin;;C:\WINDOWS\system32;;.
Apr 30, 2020 7:43:51 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
Apr 30, 2020 7:43:51 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Apr 30, 2020 7:43:51 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-nio-8009"]
Apr 30, 2020 7:43:51 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Apr 30, 2020 7:43:51 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 628 ms
Apr 30, 2020 7:43:51 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Apr 30, 2020 7:43:51 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.0.36
Apr 30, 2020 7:43:51 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.
Apr 30, 2020 7:43:51 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.
Apr 30, 2020 7:43:51 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
Apr 30, 2020 7:43:51 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8009"]
Apr 30, 2020 7:43:51 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 263 ms

Encontrou a solução?

@Artur

Não consegui

Nossa, cara, eu to ficando chateado já.. nenhum moderador pra dar força, e eu já tendei de tudo (que sei pelo menos) pra subir esse projeto.. vinha seguindo a sequencia de aulas da formação Java e desanima parar aqui por conta de uma coisa assim :/

Coisas que eu já tentei:

  • Configurar variáveis de ambiente do JAVA_HOME e CATALINA;
  • Comentar a linha do mysql Driver/ usar Value para passar a string do driver;(dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");)
  • Instalar diversas versões diferentes do mysql;
  • Atualizar dependências;
  • Downgrade nas dependências;
  • Trocar "create-drop" por "update" e "create".

Não adianta entre outros erros, no console aparece:

[...]Error creating bean with name 'getEntityManagerFactory' [....]

E ao acessar no browser o erro 404 segue surgindo... compartilhando aqui pra caso alguém puder ajudar

SOLUCIONADO!

Resolvi mas não sei como exatamente, então fazendo tudo isso sei que no fim deu certo:

  • Configurei as variáveis de ambiente do JAVA_HOME e CATALINA;
  • Usei o mysql server 5.6;
  • Alterei o "log4j.xml" para que ficasse dessa forma:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
    debug="true">

    <appender name="stdout" class="org.apache.log4j.ConsoleAppender">
        <param name="Threshold" value="debug" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{HH:mm:ss} %p [%t]:%c{3}.%M()%L - %m%n" />
        </layout>
    </appender>

    <category name="org.springframework">
        <priority value="warn"/>
        <appender-ref ref="stdout" />
    </category>    

</log4j:configuration>
  • Alterei o web.xml para ficar dessa forma:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <display-name>Servlet 3.0 Web Application</display-name>
  • Deixei o JpaConfigurator.java dessa forma:
public class JpaConfigurator {

    @Bean
    public DataSource getDataSource() {
        DriverManagerDataSource dataSource = new DriverManagerDataSource();

        dataSource.setDriverClassName("com.mysql.jdbc.Driver");
        dataSource.setUrl("jdbc:mysql://localhost/projeto_jpa");
        dataSource.setUsername("root");
        dataSource.setPassword("123456789");

        return dataSource;
    }

    @Bean
    public LocalContainerEntityManagerFactoryBean getEntityManagerFactory(DataSource dataSource) {
        LocalContainerEntityManagerFactoryBean entityManagerFactory = new LocalContainerEntityManagerFactoryBean();

        entityManagerFactory.setPackagesToScan("br.com.caelum");
        entityManagerFactory.setDataSource(dataSource);

        entityManagerFactory.setJpaVendorAdapter(new HibernateJpaVendorAdapter());

        Properties props = new Properties();
        props.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL8Dialect");
        props.setProperty("hibernate.show_sql", "true");
        props.setProperty("hibernate.hbm2ddl.auto", "create-drop");
        entityManagerFactory.setJpaProperties(props);
        return entityManagerFactory;
    }

    @Bean
    public JpaTransactionManager getTransactionManager(EntityManagerFactory emf) {
        JpaTransactionManager transactionManager = new JpaTransactionManager();
        transactionManager.setEntityManagerFactory(emf);

        return transactionManager;
    }

}
  • Nas dependencias usei o seguinte mysql
<dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.47</version>
        </dependency>