Closing JPA Entity_Manage_Factory for persistence unit 'default'
Asked Answered
J

9

10

I am getting no-error when trying to Build, compile and Verify
But when i am trying run using Maven to run this project start getting "Closing JPA EntityManagerFactory for persistence unit 'default' HikariPool-1 - Shutdown initiated, HikariPool-1 - Shutdown completed "

Can any one help on this, Thanks in advance

"C:\Program Files\Java\jdk1.8.0_301\bin\java.exe" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:51659,suspend=y,server=n -javaagent:C:\Users\suyash.shrivastava\AppData\Local\JetBrains\IdeaIC2021.2\captureAgent\debugger-agent.jar -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.2.1\lib\idea_rt.jar" com.intellij.rt.execution.CommandLineWrapper C:\Users\suyash.shrivastava\AppData\Local\Temp\idea_classpath1870814817 com.trianz.datamesh.DatameshApplication C:/Users/suyash.shrivastava/.m2/repository
Connected to the target VM, address: '127.0.0.1:51659', transport: 'socket'
20:59:59.723 [main] INFO com.trianz.datamesh.DatameshApplication - Application Started.....

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

2021-10-18 21:00:08.117  INFO 8108 --- [           main] com.trianz.datamesh.DatameshApplication  : Starting DatameshApplication using Java 1.8.0_301 on Tri02L-DHW2R93 with PID 8108 (C:\Users\suyash.shrivastava\Documents\DataMesh\target\classes started by suyash.shrivastava in C:\Users\suyash.shrivastava\Documents\DataMesh)
2021-10-18 21:00:08.119  INFO 8108 --- [           main] com.trianz.datamesh.DatameshApplication  : The following profiles are active: local
2021-10-18 21:00:10.489  INFO 8108 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-10-18 21:00:11.144  INFO 8108 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 622 ms. Found 4 JPA repository interfaces.
2021-10-18 21:00:14.345  INFO 8108 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-10-18 21:00:14.641  INFO 8108 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.4.32.Final
2021-10-18 21:00:15.300  INFO 8108 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-10-18 21:00:16.082  INFO 8108 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2021-10-18 21:00:16.809  INFO 8108 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2021-10-18 21:00:16.884  INFO 8108 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
Hibernate: create table dm_dataset (id bigint generated by default as identity, athena_query_sql varchar(255), column_list_with_types varchar(255), dataset_name varchar(255), db_sql varchar(255), description varchar(255), frequency varchar(255), schema_path varchar(255), table_name varchar(255), datasource_id bigint not null, primary key (id))
Hibernate: create table dm_datasource (datasource_id bigint generated by default as identity, athena_data_source_name varchar(255), database varchar(255), db_type varchar(255), description varchar(255), host varchar(255), name varchar(255), password varchar(255), schema varchar(255), username varchar(255), domain_id bigint not null, primary key (datasource_id))
Hibernate: create table dm_domain (domain_id bigint generated by default as identity, domain_description varchar(255), domain_name varchar(255), domain_owner varchar(255), frequency varchar(255), primary key (domain_id))
Hibernate: create table udfdgrules (id bigint generated by default as identity, apply_column_name varchar(255), udf_alias_inaws varchar(255), udf_input_parameter_type varchar(255), udf_name varchar(255) not null, udf_return_type varchar(255), user_id bigint not null, primary key (id))
Hibernate: alter table dm_dataset add constraint FK3q5ryjfrcurqxid5bd303a88y foreign key (datasource_id) references dm_datasource
Hibernate: alter table dm_datasource add constraint FKhcev25r3f4d74aaf63rec8786 foreign key (domain_id) references dm_domain
2021-10-18 21:00:20.863  INFO 8108 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-10-18 21:00:20.903  INFO 8108 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-10-18 21:00:26.996  INFO 8108 --- [           main] org.neo4j.driver.Driver                  : Direct driver instance 147735328 created for server address localhost:7687
2021-10-18 21:00:27.366  INFO 8108 --- [           main] com.trianz.datamesh.DatameshApplication  : Started DatameshApplication in 21.184 seconds (JVM running for 28.361)
2021-10-18 21:01:20.393  WARN 8108 --- [l-1 housekeeper] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=57s713ms652µs100ns).
2021-10-18 21:02:12.019  WARN 8108 --- [l-1 housekeeper] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=57s378ms596µs700ns).
2021-10-18 21:02:24.298  INFO 8108 --- [           main] com.trianz.datamesh.DatameshApplication  : Application Running
2021-10-18 21:02:46.579  INFO 8108 --- [ionShutdownHook] org.neo4j.driver.Driver                  : Closing driver instance 147735328
2021-10-18 21:02:46.862  INFO 8108 --- [ionShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2021-10-18 21:02:46.872  INFO 8108 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2021-10-18 21:02:46.884  INFO 8108 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.

This is my Pom.XML file

<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.2</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.trianz.datamesh</groupId>
    <artifactId>datamesh</artifactId>
    <version>0.0.1</version>
    <packaging>war</packaging>
    <name>datamesh</name>
    <description>datamesh mvp 2 athena</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>


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

        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>42.2.14</version>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>jakarta.validation</groupId>
            <artifactId>jakarta.validation-api</artifactId>
            <version>2.0.2</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>


        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.9.2</version>
        </dependency>

        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.9.2</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.modelmapper/modelmapper -->
        <dependency>
            <groupId>org.modelmapper</groupId>
            <artifactId>modelmapper</artifactId>
            <version>2.4.4</version>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>

        <!--<dependency>-->
        <!--<groupId>org.springframework.kafka</groupId>-->
        <!--<artifactId>spring-kafka</artifactId>-->
        <!--</dependency>-->

        <dependency>
            <groupId>org.springframework.kafka</groupId>
            <artifactId>spring-kafka</artifactId>
            <version>2.7.0</version>
        </dependency>

        <dependency>
            <groupId>org.apache.kafka</groupId>
            <artifactId>kafka-clients</artifactId>
            <version>2.8.0</version>
        </dependency>



        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>


        <dependency>
            <groupId>org.junit.vintage</groupId>
            <artifactId>junit-vintage-engine</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.hamcrest</groupId>
                    <artifactId>hamcrest-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>




        <dependency>
            <groupId>org.springframework.kafka</groupId>
            <artifactId>spring-kafka-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>


        <dependency>
            <groupId>com.amazon.redshift</groupId>
            <artifactId>redshift-jdbc42</artifactId>
            <version>2.1.0.1</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.neo4j.driver/neo4j-java-driver -->
        <dependency>
            <groupId>org.neo4j.driver</groupId>
            <artifactId>neo4j-java-driver</artifactId>
            <version>4.3.2</version>
        </dependency>


        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>aws-sdk-java</artifactId>
            <version>2.7.20</version>
        </dependency>

        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk</artifactId>
            <version>1.11.586</version>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20201115</version>
        </dependency>

    </dependencies>



    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>
Jarl answered 18/10, 2021 at 16:20 Comment(0)
J
5

1. Remove the spaces between the dependency

2. Update the Parent Version"spring-boot-starter-parent 2.5.5.

3. Remove the scope from "spring-boot-starter-tomcat"

<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.5</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.trianz.datamesh</groupId>
    <artifactId>datamesh</artifactId>
    <version>0.0.1</version>
    <packaging>war</packaging>
    <name>datamesh</name>
    <description>datamesh mvp 2 athena</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>42.2.14</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>jakarta.validation</groupId>
            <artifactId>jakarta.validation-api</artifactId>
            <version>2.0.2</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.9.2</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.9.2</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.modelmapper/modelmapper -->
        <dependency>
            <groupId>org.modelmapper</groupId>
            <artifactId>modelmapper</artifactId>
            <version>2.4.4</version>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.kafka</groupId>
            <artifactId>spring-kafka</artifactId>
            <version>2.7.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.kafka</groupId>
            <artifactId>kafka-clients</artifactId>
            <version>2.8.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.junit.vintage</groupId>
            <artifactId>junit-vintage-engine</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.hamcrest</groupId>
                    <artifactId>hamcrest-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.kafka</groupId>
            <artifactId>spring-kafka-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
        <dependency>
            <groupId>com.amazon.redshift</groupId>
            <artifactId>redshift-jdbc42</artifactId>
            <version>2.1.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.neo4j.driver</groupId>
            <artifactId>neo4j-java-driver</artifactId>
            <version>4.3.2</version>
        </dependency>
        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>aws-sdk-java</artifactId>
            <version>2.7.20</version>
        </dependency>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk</artifactId>
            <version>1.11.586</version>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20201115</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>
Jarl answered 18/10, 2021 at 16:27 Comment(0)
A
4

You might want to comment or totally remove this dependency:

 <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
</dependency>

There is a possible conflict between "spring-boot-starter-web" and "spring-boot-starter-tomcat". The former already takes care of tomcat.

Read more here: spring-boot-starter-tomcat vs spring-boot-starter-web

Aboutface answered 28/1, 2022 at 7:43 Comment(1)
is there any other possiblity of casing of this issue. I dont have spring-boot-starter-tomcat on my pom.xml but still this issue is troubling meWhitelivered
C
1

Your pom.xml contains both the spring-boot-starter-web and spring-boot-starter-tomcat dependencies. This is redundant as the former has a default embedded tomcat.

Take out the spring-boot-starter-tomcat dependency, that is,

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

Run mvn clean install and then run the spring application once you get a BUILD SUCCESS

Connective answered 24/2, 2022 at 2:16 Comment(0)
A
1

The issue is sometimes related to minimum 1 endpoint to start in spring boot application.

Please add @Component, @Controller, etc endpoint to start with in your class file.

The issue will resolve try this.

Anna answered 12/7, 2023 at 7:44 Comment(0)
R
1

This is because of conflict in spring.boot.starter.tomcat dependency. It is already there in spring.boot.starter.web.
Exclude the spring.boot.starter.tomcat will resolve the issue.

<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>
Ramsay answered 9/9, 2023 at 5:59 Comment(0)
I
0

If you want a WAR type spring boot application, then remove spring.main.web-application-type=none from your application.yml file.Also do as below in build.gradle.

implementation("org.springframework.boot:spring-boot-starter-web") {
    exclude module: "spring-boot-starter-tomcat"
}
providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')

After that clean and refresh your dependency as below:

gradlew clean build

gradlew --refresh-dependencies
Izanami answered 7/3, 2023 at 12:56 Comment(0)
U
0

Just Follow the bellow simple points.

Delete your .m2 Folder in C:/users/.

Install Apache maven from https://maven.apache.org/download.cgi (if its not installed)

Keep extracted folder in C: drive

Add path variable the location of bin folder. (C:\apache-maven-3.9.1\bin)

Maven -Clean > Maven -Install > now run your application.

Unmixed answered 7/4, 2023 at 7:11 Comment(0)
B
0

For me, in Windows, the important things was install maven client:

-https://maven.apache.org/install.html ,

-obviously extract folder from zip,

-add the bin folder in the enviroment path.

After that RESTART intellij or Eclipse and run in the root folder of your app:

-remove tomcat dependency

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>

-launch command: mvn clean install (as told in the previous answers)

-Start the app

Without this command the dependency will not refresh and the error will remains.

Balaam answered 15/5, 2023 at 10:13 Comment(0)
T
0

Sorry its bit late but for me, updating the spring version worked from 3.0.6 to 3.1.4 as my pom.xml had open feign dependencies which were not supported by 3.0.6 after Sep 19, 2023 (as provided in below link).

https://spring.io/projects/spring-cloud-openfeign#overview

Tertullian answered 30/9, 2023 at 19:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.