title: Maven build error: Closing JPA EntityManagerFactory for persistence unit 'default'
body: <p>I'm trying to compile a maven project but it just won't work, I've tried compiling it java 1.8 and in jar and it worked well, but it ran the code properly but would compile to jar, but that's besides the point; This code in java 11 won't even run and i'm not sure why. I've tried all of <a href="https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000181384-Spring-Boot-Application-immediately-closing-after-startup-" rel="nofollow noreferrer">these</a> tricks people said but most of them was already added from spring initializer.</p>
  <p><a href="https://docs.google.com/document/d/1S3o2ASOgRZZEJOXy33DmqO0QkTASutSN/edit?usp=sharing&amp;ouid=104484606463635748694&amp;rtpof=true&amp;sd=true" rel="nofollow noreferrer"><strong>ERROR WITH DEBUG ON</strong></a></p>
  <p><code>pom.xml</code></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
      xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;2.5.3&lt;/version&gt;
          &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
  
      &lt;/parent&gt;
      &lt;groupId&gt;com.api.anonyomail&lt;/groupId&gt;
      &lt;artifactId&gt;AnonyomailREST&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
      &lt;name&gt;AnonyomailREST&lt;/name&gt;
      &lt;description&gt;REST Api for anonyomail&lt;/description&gt;
      &lt;properties&gt;
          &lt;java.version&gt;11&lt;/java.version&gt;
      &lt;/properties&gt;
  
  
      &lt;dependencies&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
  
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;version&gt;8.0.21&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.vaadin.external.google&lt;/groupId&gt;
              &lt;artifactId&gt;android-json&lt;/artifactId&gt;
              &lt;version&gt;0.0.20131108.vaadin1&lt;/version&gt;
              &lt;scope&gt;compile&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.vaadin.external.google&lt;/groupId&gt;
              &lt;artifactId&gt;android-json&lt;/artifactId&gt;
              &lt;version&gt;0.0.20131108.vaadin1&lt;/version&gt;
              &lt;scope&gt;compile&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.xml.bind&lt;/groupId&gt;
              &lt;artifactId&gt;jaxb-api&lt;/artifactId&gt;
              &lt;version&gt;2.3.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jaxb&lt;/groupId&gt;
              &lt;artifactId&gt;jaxb-core&lt;/artifactId&gt;
              &lt;version&gt;2.3.0.1&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.xml.bind&lt;/groupId&gt;
              &lt;artifactId&gt;jaxb-impl&lt;/artifactId&gt;
              &lt;version&gt;2.3.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jaxb&lt;/groupId&gt;
              &lt;artifactId&gt;jaxb-runtime&lt;/artifactId&gt;
              &lt;version&gt;2.3.2&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.xml.ws&lt;/groupId&gt;
              &lt;artifactId&gt;jaxws-ri&lt;/artifactId&gt;
              &lt;version&gt;2.3.0&lt;/version&gt;
              &lt;type&gt;pom&lt;/type&gt;
          &lt;/dependency&gt;
  
      &lt;/dependencies&gt;
  
  
  
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>
  <p><code>error</code></p>
  <pre><code>  .   ____          _            __ _ _
   /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
  ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
   \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
    '  |____| .__|_| |_|_| |_\__, | / / / /
   =========|_|==============|___/=/_/_/_/
   :: Spring Boot ::                (v2.5.3)
  
  2021-08-12 16:49:31.589  INFO 88987 --- [           main] c.a.a.A.AnonyomailRestApplication        : Starting AnonyomailRestApplication using Java 16.0.1 on Macbook-Air with PID 88987 (/Users/danielcaminero/AnonyomailREST/target/classes started by danielcaminero in /Users/danielcaminero/AnonyomailREST)
  2021-08-12 16:49:31.594  INFO 88987 --- [           main] c.a.a.A.AnonyomailRestApplication        : No active profile set, falling back to default profiles: default
  2021-08-12 16:49:32.624  INFO 88987 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
  2021-08-12 16:49:32.782  INFO 88987 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 136 ms. Found 1 JPA repository interfaces.
  2021-08-12 16:49:33.458  INFO 88987 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
  2021-08-12 16:49:33.565  INFO 88987 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.4.32.Final
  2021-08-12 16:49:33.852  INFO 88987 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
  2021-08-12 16:49:34.073  INFO 88987 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
  2021-08-12 16:49:35.140  INFO 88987 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
  2021-08-12 16:49:35.208  INFO 88987 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL57Dialect
  2021-08-12 16:49:36.628  INFO 88987 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
  2021-08-12 16:49:36.645  INFO 88987 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
  2021-08-12 16:49:37.112  INFO 88987 --- [           main] c.a.a.A.AnonyomailRestApplication        : Started AnonyomailRestApplication in 6.617 seconds (JVM running for 7.522)
  2021-08-12 16:49:37.117  INFO 88987 --- [ionShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
  2021-08-12 16:49:37.120  INFO 88987 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
  2021-08-12 16:49:37.158  INFO 88987 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
  </code></pre>
  <hr />
  <p><strong>THE TEXT BELOW IS FROM A DIFFERENT VERSION OF JAVA AND MAVEN WHEN ITS WORKING FINE</strong></p>
  <p><code>pom.xml</code></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
      xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;2.5.3&lt;/version&gt;
          &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
      &lt;groupId&gt;com.AnonyomailREST.example&lt;/groupId&gt;
      &lt;artifactId&gt;rest&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;name&gt;AnonyomailRESTapi&lt;/name&gt;
      &lt;description&gt;Anonyomail&amp;apos;s REST API&lt;/description&gt;
      &lt;packaging&gt;jar&lt;/packaging&gt;
      &lt;properties&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
      &lt;/properties&gt;
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;version&gt;8.0.21&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.vaadin.external.google&lt;/groupId&gt;
              &lt;artifactId&gt;android-json&lt;/artifactId&gt;
              &lt;version&gt;0.0.20131108.vaadin1&lt;/version&gt;
              &lt;scope&gt;compile&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.vaadin.external.google&lt;/groupId&gt;
              &lt;artifactId&gt;android-json&lt;/artifactId&gt;
              &lt;version&gt;0.0.20131108.vaadin1&lt;/version&gt;
              &lt;scope&gt;compile&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.mail&lt;/groupId&gt;
              &lt;artifactId&gt;jakarta.mail&lt;/artifactId&gt;
              &lt;version&gt;1.6.4&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>
  <p><code>terminal</code></p>
  <pre><code>  .   ____          _            __ _ _
   /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
  ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
   \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
    '  |____| .__|_| |_|_| |_\__, | / / / /
   =========|_|==============|___/=/_/_/_/
   :: Spring Boot ::                (v2.5.3)
  
  2021-08-12 17:20:52.206  INFO 89283 --- [           main] c.A.e.rest.AnonyomailResTapiApplication  : Starting AnonyomailResTapiApplication using Java 1.8.0_301 on Macbook-Air with PID 89283 (/Users/danielcaminero/rest/target/classes started by danielcaminero in /Users/danielcaminero/rest)
  2021-08-12 17:20:52.214  INFO 89283 --- [           main] c.A.e.rest.AnonyomailResTapiApplication  : No active profile set, falling back to default profiles: default
  2021-08-12 17:20:55.129  INFO 89283 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
  2021-08-12 17:20:55.256  INFO 89283 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 104 ms. Found 1 JPA repository interfaces.
  2021-08-12 17:20:56.851  INFO 89283 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
  2021-08-12 17:20:56.890  INFO 89283 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
  2021-08-12 17:20:56.890  INFO 89283 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.50]
  2021-08-12 17:20:57.228  INFO 89283 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
  2021-08-12 17:20:57.228  INFO 89283 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 4607 ms
  2021-08-12 17:20:57.951  INFO 89283 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
  2021-08-12 17:20:58.083  INFO 89283 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.4.32.Final
  2021-08-12 17:20:58.477  INFO 89283 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
  2021-08-12 17:20:58.671  INFO 89283 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
  2021-08-12 17:20:59.756  INFO 89283 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
  2021-08-12 17:20:59.850  INFO 89283 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL57Dialect
  2021-08-12 17:21:01.603  INFO 89283 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
  2021-08-12 17:21:01.617  INFO 89283 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
  2021-08-12 17:21:02.619  WARN 89283 --- [           main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
  2021-08-12 17:21:03.399  INFO 89283 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
  2021-08-12 17:21:03.421  INFO 89283 --- [           main] c.A.e.rest.AnonyomailResTapiApplication  : Started AnonyomailResTapiApplication in 13.927 seconds (JVM running for 15.899)
  2021-08-12 17:21:28.170  INFO 89283 --- [nio-8080-exec-2] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
  2021-08-12 17:21:28.171  INFO 89283 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
  </code></pre>