본문 바로가기

오류 노트

[Spring] SEVERE: Context initialized 이벤트를 [org.springframework.web.context.ContextLoaderListener] 클래스의 인스턴스인 리스너에 전송하는 동안 예외 발생org.springframework.beans.factory.BeanCreationException: Error creating ..

반응형

오류 내용

Spring으로 팀프로젝트 사이트를 접속하려고 했는데 오류가 났다. 

 

SEVERE: Context initialized 이벤트를 [org.springframework.web.context.ContextLoaderListener] 클래스의 인스턴스인 리스너에 전송하는 동안 예외 발생

 

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'datasource' defined in Serv

letContextresource [/WEB-INF/spring/root-context.xml]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException:Failedtoinstantiate

 

 

[com.zaxxer.hikari.HikariDataSource]: Constructor threw exception; nested exception is co m.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: FATAL: remaining connection slots are reserved for non-replication superuser connections

 

 

오류  원인

해당 오류는 데이터 소스 빈을 초기화하는 동안 문제가 발생했음을 나타낸다. 더 구체적으로는, PostgreSQL 데이터베이스에서 사용 가능한 연결 슬롯이 모두 비-복제 슈퍼유저 연결에 예약되어 있는 상태다.

이러한 문제의 일반적인 원인은 PostgreSQL 데이터베이스 서버에 동시에 허용되는 연결 수를 초과했거나, 권한이 부여된 사용자로 접속할 수 있는 연결 슬롯이 부족한 경우다.

 

해결 방법

1. PostgreSQL 데이터베이스 서버 설정 검토 : PostgreSQL 서버의 최대 연결 수 설정을 확인하고 필요한 경우 수정해야 한다. 이 설정은 postgresql.conf 파일에서 max_connections로 찾을 수 있다. 충분한 연결 수를 설정해야 한다.

2. 연결 슬롯 해제 : 복제를 사용하지 않는 슈퍼유저 연결 슬롯을 해제하여 사용 가능한 연결 슬롯을 늘릴 수 있다. PostgreSQL에서는 슈퍼유저로 로그인하여 해당 연결 슬롯을 해제해야 한다. 다음 명령어를 사용할 수 있다

SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = 'your_database_name' AND usename = 'your_superuser_name';

위 명령에서 'your_database_name'은 데이터베이스 이름, 'your_superuser_name'은 슈퍼유저 사용자 이름으로 바꿔주어야 한다. 

 


DB관리자님이 기존에 연결되어 있는 사용자들을 해제시키고 TimeOut 설정을 다시하셨다. 그러니 문제가 해결됐다. 

반응형