4
respostas

Problema para iniciar o servidor Jetty

Prezado,

            Solicito suporte para problema de inicialização do servidor Jetty.  Ao executar a aplicação, identifiquei que o servidor não está sendo iniciado.

        Segue abaixo o conteúdo do arquivo POM.xml

4.0.0 br.com.alura.listavip listavip 0.0.1-SNAPSHOT

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>2.1.3.RELEASE</version>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-jetty -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jetty</artifactId>
        <version>2.1.3.RELEASE</version>
    </dependency>


    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
        <version>2.1.3.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
        <version>2.1.3.RELEASE</version>
    </dependency>

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

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
        <version>2.1.3.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>br.com.alura.enviadorEmail</groupId>
        <artifactId>enviadorEmail</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>
</dependencies>
        Segue o log do Console do Eclipse abaixo:
2019-04-02 23:24:15.076  INFO 21040 --- [restartedMain] br.com.alura.listavip.Configuracao       : Starting Configuracao on DESKTOP-33GUH60 with PID 21040 (C:\workspace\listavip\target\classes started by mdomi in C:\workspace\listavip)
2019-04-02 23:24:15.086  INFO 21040 --- [restartedMain] br.com.alura.listavip.Configuracao       : No active profile set, falling back to default profiles: default
2019-04-02 23:24:15.134  INFO 21040 --- [restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2019-04-02 23:24:15.661  INFO 21040 --- [restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-04-02 23:24:15.744  INFO 21040 --- [restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 65ms. Found 1 repository interfaces.
2019-04-02 23:24:16.904  INFO 21040 --- [restartedMain] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
    name: default
    ...]
2019-04-02 23:24:16.987  INFO 21040 --- [restartedMain] org.hibernate.Version                    : HHH000412: Hibernate Core {5.3.7.Final}
2019-04-02 23:24:16.988  INFO 21040 --- [restartedMain] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2019-04-02 23:24:17.150  INFO 21040 --- [restartedMain] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.4.Final}
2019-04-02 23:24:17.317  INFO 21040 --- [restartedMain] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2019-04-02 23:24:17.899  INFO 21040 --- [restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2019-04-02 23:24:18.480  INFO 21040 --- [restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2019-04-02 23:24:18.495  INFO 21040 --- [restartedMain] br.com.alura.listavip.Configuracao       : Started Configuracao in 3.829 seconds (JVM running for 4.339)
2019-04-02 23:24:18.501  INFO 21040 --- [Thread-8] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
4 respostas

Oi Marcelo! Tudo bem?

Percebi uma coisa que não me pareceu bem no seu código. A documentação do spring boot, ou utilizando o spring initialzr, todo projeto spring boot deve ser filho de um pom pai do spring boot.

Quando você fizer isso, ele herda configurações do pai e você não mais precisa colocar, por exemplo, as versões das dependências do spring boot no seu pom.xml

Como era só para testar, removi a dependencia do envio de email e JPA já que não tenho banco configurado aqui e subiu bonito.

Att,

Rodrigo

POM.XML

<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>alura</groupId>
  <artifactId>forumalura81399</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <!-- Valide que vc tem o parent no seu pom.xml -->
      <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.3.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

  <dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-jetty -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jetty</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>

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

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
    </dependency>

</dependencies>
</project>

E segue o log de inicialização:


  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.3.RELEASE)

com.example.demo.DemoApplication         : Starting DemoApplication on Rodrigos-MBP-7 with PID 64936 (/Users/rpcosta/Desktop/Alura/forumalura81399/target/classes started by rpcosta in /Users/rpcosta/Desktop/Alura/forumalura81399)
com.example.demo.DemoApplication         : No active profile set, falling back to default profiles: default
.e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
.e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
org.eclipse.jetty.util.log               : Logging initialized @5326ms to org.eclipse.jetty.util.log.Slf4jLog
o.s.b.w.e.j.JettyServletWebServerFactory : Server initialized with port: 8080
org.eclipse.jetty.server.Server          : jetty-9.4.14.v20181114; built: 2018-11-14T21:20:31.478Z; git: c4550056e785fb5665914545889f21dc136ad9e6; jvm 1.8.0_171-b11
o.e.j.s.h.ContextHandler.application     : Initializing Spring embedded WebApplicationContext
o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 3201 ms
org.eclipse.jetty.server.session         : DefaultSessionIdManager workerName=node0
org.eclipse.jetty.server.session         : No SessionScavenger set, using defaults
org.eclipse.jetty.server.session         : node0 Scavenging every 660000ms
o.e.jetty.server.handler.ContextHandler  : Started o.s.b.w.e.j.JettyEmbeddedWebAppContext@39ddb988{application,/,[file:///private/var/folders/pp/q97n6f014wl96q52r65jc2j40000gn/T/jetty-docbase.6497257603382190249.8080/],AVAILABLE}
org.eclipse.jetty.server.Server          : Started @6010ms
o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
ion$DefaultTemplateResolverConfiguration : Cannot find template location: classpath:/templates/ (please add some templates or check your Thymeleaf configuration)
o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
o.e.j.s.h.ContextHandler.application     : Initializing Spring DispatcherServlet 'dispatcherServlet'
o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
o.s.web.servlet.DispatcherServlet        : Completed initialization in 21 ms
o.e.jetty.server.AbstractConnector       : Started ServerConnector@5a217cde{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
o.s.b.web.embedded.jetty.JettyWebServer  : Jetty started on

Prezado Professor,

          Coloquei esse POM que o sr. postou aqui no Forum e continuou não subindo o servidor do Jetty. Porém resolvi fazer um teste com as versões anteriores e percebi que o Jetty só inicia na minha máquina até a versão 2.1.1 do s-pring-boot. Versóes posteriores a essa o Jetty não inicia mais. Será que é bug do framework pelo fato da versáo ser mais recente ?