1
resposta

Exception in thread "task-2" java.lang.IllegalStateException: EntityManagerFactory is closed

Olá pessoal, podem me auxiliar? Estou recebendo a seguinte mensagem de erro:

2022-02-14 08:23:27.509  WARN 18620 --- [  restartedMain] 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
2022-02-14 08:23:27.880  WARN 18620 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : Unable to start LiveReload server
2022-02-14 08:23:27.924  WARN 18620 --- [  restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.PortInUseException: Port 8080 is already in use
Exception in thread "task-2" java.lang.IllegalStateException: EntityManagerFactory is closed
    at org.hibernate.internal.SessionFactoryImpl.validateNotClosed(SessionFactoryImpl.java:509)
    at org.hibernate.internal.SessionFactoryImpl.getProperties(SessionFactoryImpl.java:503)
    at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher.findDataSource(DataSourceInitializedPublisher.java:105)
    at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher.publishEventIfRequired(DataSourceInitializedPublisher.java:97)
    at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher.access$100(DataSourceInitializedPublisher.java:50)
    at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher$DataSourceSchemaCreatedPublisher.lambda$postProcessEntityManagerFactory$0(DataSourceInitializedPublisher.java:200)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:833)
2022-02-14 08:23:28.526  WARN 18620 --- [  restartedMain] o.s.b.f.support.DisposableBeanAdapter    : Invocation of destroy method failed on bean with name 'inMemoryDatabaseShutdownExecutor': org.h2.jdbc.JdbcSQLNonTransientConnectionException: Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL) [90121-200]
2022-02-14 08:23:28.540 ERROR 18620 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Web server failed to start. Port 8080 was already in use.

Action:

Identify and stop the process that's listening on port 8080 or configure this application to listen on another port.

1 resposta

Olá Tatiana, tudo bem?

Pelo erro apresentado, parece que você está tentando iniciar um servidor em uma porta que já está em uso. O erro "Port 8080 is already in use" indica que a porta 8080 já está sendo utilizada por outro processo.

Para resolver esse problema, você pode tentar identificar qual processo está utilizando a porta 8080 e finalizá-lo ou configurar o seu servidor para utilizar outra porta. Para verificar qual processo está utilizando a porta 8080, você pode utilizar o comando "lsof -i :8080" no terminal do seu sistema operacional.

Além disso, o erro "EntityManagerFactory is closed" pode estar relacionado a uma configuração incorreta do seu banco de dados. Verifique se as configurações do seu banco de dados estão corretas e se a conexão está sendo estabelecida corretamente.

Espero ter ajudado e bons estudos!