'눈사람은 어디에?' 프로젝트 에러 모음

ran·2023년 12월 21일

오류기록

목록 보기
4/4

눈사람은 어디에?

동국톤 1기에서 만든 서비스로 겨울성 이벤트 서비스이다.
여기서 기획, 개발, 배포까지 앤드 투 앤드로 개발을 하였다.
아래의 링크에서 프로젝트를 확인할 수 있다.

[동국톤] 눈사람은 어디에? BE


회고

이번 프로젝트에서 사실 백단의 모든것을 다 개발한것 같다.
같이 하는 팀원은 프론트엔드에서 백엔드로 전환하여서 공부한지 얼마 안되고, 해당 인원의 첫 백엔드 프로젝트여서 간단하게 마이페이지 정도만 부탁을 했고, 그 외의 백앤드 코드와 GCP 인프라 구성은 내가 하였다.

하지만, 프론트엔드가 사실상 거의 완성이 안됐다. 프론트엔드 팀원은 둘다 리액트가 처음이고, 3일안에 개발을 하는게 사실상 무리였다.(공부할 시간은 있었는데..)

그래서 api를 나름 최소화했는데,,, 대회 마감 2시간전에 들은 말이 아직도 충격적이다.. "나 통신할줄 모르는데" ...라는 말은 아직도 잊혀지지 않는다..

이 부분을 미리 체크를 못한게 개발 팀장으로써 놓친 부분일 수 있으나.. 난 당연히 axios 통신정도는 프론트를 하는데 할줄 알거라고 생각했다...

결과는 프론트 배포를 못하고, 마무리됐다.

예전 프로젝트부터 항상 프론트가 문제였다. 아무래도 개발을 주로 하는 학과가 아니기 때문에 프론트 인원들이 경험이 부족했다..

그래서 이번 계기로 느낀게 그냥 내가 프론트쪽도 다룰줄 알아야겠다는 생각을 하게 됐다. 안그래도 동국톤에서 드로우로 상품으로 프론트 강의를 뽑은김에 리액트 정도는 할 줄 알아서 나름 풀스택? 을 지향하는 쪽으로 가보려고 한다..😂😂

그리고 디자이너의 유무의 차이를 크게 느꼈다.! 우리팀 디자이너분 너무 감사했습니다!


에러 모음

1. hibernate-spatial 에러

현재 스프링 3점대를 사용하고 있다.
이번 프로젝트에서 처음으로 위치 기반 서비를 제공하기 때문에 hibernate-spatial 의존성이 필요해져서 아래와 같은 라이브러리를 넣었다.

implementation group: 'org.hibernate', name: 'hibernate-spatial', version: '5.6.9.Final'

그런데, 해당 라이브러리 적용 후 아래와 같은 에러들이 발생하며 run이 안됐다.

2023-12-19T17:46:21.516+09:00  WARN 30209 --- [           main] org.hibernate.orm.deprecation            : HHH90000025: MySQLDialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default)
2023-12-19T17:46:21.587+09:00 ERROR 30209 --- [           main] o.s.b.web.embedded.tomcat.TomcatStarter  : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'securityConfig' defined in file [/Users/ran/Desktop/동국대학교/프로젝트_대회/동국톤/Showman/out/production/classes/com/donggukthon/Showman/config/SecurityConfig.class]: Unsatisfied dependency expressed through constructor parameter 1: Error creating bean with name 'jwtService' defined in file [/Users/ran/Desktop/동국대학교/프로젝트_대회/동국톤/Showman/out/production/classes/com/donggukthon/Showman/config/jwt/JwtService.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'userRepository' defined in com.donggukthon.Showman.repository.UserRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Cannot resolve reference to bean 'jpaSharedEM_entityManagerFactory' while setting bean property 'entityManager'
2023-12-19T17:46:21.603+09:00  INFO 30209 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2023-12-19T17:46:21.604+09:00  WARN 30209 --- [           main] o.a.c.loader.WebappClassLoaderBase       : The web application [ROOT] appears to have started a thread named [HikariPool-1 housekeeper] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.base@17.0.8/jdk.internal.misc.Unsafe.park(Native Method)
 java.base@17.0.8/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:252)
.
.
.
2023-12-19T17:46:21.604+09:00  WARN 30209 --- [           main] o.a.c.loader.WebappClassLoaderBase       : The web application [ROOT] appears to have started a thread named [HikariPool-1 connection adder] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.base@17.0.8/sun.nio.ch.Net.poll(Native Method)
 java.base@17.0.8/sun.nio.ch.NioSocketImpl.park(NioSocketImpl.java:181)
 java.base@17.0.8/sun.nio.ch.NioSocketImpl.timedRead(NioSocketImpl.java:285)
 java.base@17.0.8/sun.nio.ch.NioSocketImpl.implRead(NioSocketImpl.java:309)
 java.base@17.0.8/sun.nio.ch.NioSocketImpl.read(NioSocketImpl.java:350)
 java.base@17.0.8/sun.nio.ch.NioSocketImpl$1.read(NioSocketImpl.java:803)
 java.base@17.0.8/java.net.Socket$SocketInputStream.read(Socket.java:966)
 app//com.mysql.cj.protocol.ReadAheadInputStream.fill(ReadAheadInputStream.java:107)
 app//com.mysql.cj.protocol.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:150)
 app//com.mysql.cj.protocol.ReadAheadInputStream.read(ReadAheadInputStream.java:180)
 java.ba
 .
 .
 .
 org.springframework.context.ApplicationContextException: Unable to start web server
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:164) ~[spring-boot-3.1.6.jar:3.1.6]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:610) ~[spring-context-6.0.14.jar:6.0.14]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.1.6.jar:3.1.6]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:738) ~[spring-boot-3.1.6.jar:3.1.6]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:440) ~[spring-boot-3.1.6.jar:3.1.6]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) ~[spring-boot-3.1.6.jar:3.1.6]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-3.1.6.jar:3.1.6]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-3.1.6.jar:3.1.6]
	at com.donggukthon.Showman.ShowmanApplication.main(ShowmanApplication.java:10) ~[classes/:na]
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
	at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:142) ~[spring-boot-3.1.6.jar:3.1.6]
	at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:104) ~[spring-boot-3.1.6.jar:3.1.6]
	at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:489) ~[spring-boot-3.1.6.jar:3.1.6]
	at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:211) ~[spring-boot-3.1.6.jar:3.1.6]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:183) ~[spring-boot-3.1.6.jar:3.1.6]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:161) ~[spring-boot-3.1.6.jar:3.1.6]
	... 8 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'securityConfig' defined in file [/Users/ran/Desktop/동국대학교/프로젝트_대회/동국톤/Showman/out/production/classes/com/donggukthon/Showman/config/SecurityConfig.class]: Unsatisfied dependency expressed through constructor parameter 1: Error creating bean with name 'jwtService' defined in file [/Users/ran/Desktop/동국대학교/프로젝트_대회/동국톤/Showman/out/production/classes/com/donggukthon/Showman/config/jwt/JwtService.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'userRepository' defined in com.donggukthon.Showman.repository.UserRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Cannot resolve reference to bean 'jpaSharedEM_entityManagerFactory' while setting bean property 'entityManager'
.
.
.
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'jwtService' defined in file [/Users/ran/Desktop/동국대학교/프로젝트_대회/동국톤/Showman/out/production/classes/com/donggukthon/Showman/config/jwt/JwtService.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'userRepository' defined in com.donggukthon.Showman.repository.UserRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Cannot resolve reference to bean 'jpaSharedEM_entityManagerFactory' while setting bean property 'entityManager'
.
.
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository' defined in com.donggukthon.Showman.repository.UserRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Cannot resolve reference to bean 'jpaSharedEM_entityManagerFactory' while setting bean property 'entityManager'

Caused by: java.lang.IllegalArgumentException: Unknown access type record
	at org.hibernate.annotations.common.reflection.java.JavaXClass.getDeclaredProperties(JavaXClass.java:118) ~[hibernate-commons-annotations-5.1.2.Final.jar:5.1.2.Final]
	at org.hibernate.annotations.common.reflection.java.JavaXClass.getDeclaredProperties(JavaXClass.java:108) ~[hibernate-commons-annotations-5.1.2.Final.jar:5.1.2.Final]
	at org.hibernate.boot.model.internal.PropertyContainer.<init>(PropertyContainer.java:90) ~[hibernate-core-6.2.13.Final.jar:6.2.13.Final]
	

처음에는 mysql 설정 문제, security 문제 등이 에러가 나는 줄 알았다. 그래서 이짓 저짓 다 하다가 그냥 에러 나기 전의 브랜치로 넘어가서 한단계씩 추가하면서 run을 해보니..

implementation group: 'org.hibernate', name: 'hibernate-spatial', version: '5.6.9.Final'

해당 라이브러리 주입에 문제가 발생한것이었다.. 즉, spatial 버전이 현재 스프링과 맞지 않던것이다.

그래서 버전을 가장 최신버전인 6.4.1로 바꿔주니 해결되었다.!

	implementation group: 'org.hibernate.orm', name: 'hibernate-spatial', version: '6.4.1.Final'

JPA Method 명명

어느순간부터 run이 제대로 되지 않고, bean이 unsatified 하다는 에러가 등장했다. 그래서 bean이 잘 주입안되는 문제라고 생각하고 bean들을 확인했는데, 아무 문제가 없었다.

에러 본문을 잘 읽어보니, 마지막에 repository에 관한 이야기가 있었다.
그래서 서치를 해보니, jpa 메서드를 잘못 만든경우에 해당 에러가 발생하는 것을 확인했다.

JPA를 사용할때는 항상 메서드 명명 규칙에 유의하고 작성하도록 하자.


GCS + Github actions

Google Cloud Storage를 처음 써보았는데, 해당 서비스는 AWS랑은 다르게 key 값을 발급받는 대신 json 파일을 발급해준다.(json 안에 정보가 존재)
그래서 나는 해당 json 파일을 github secrete으로 설정하고, cicd 돌때, 해당 파일을 resource에 복사해주는 cicd를 구상했다.

그런데, 아래와 유사하게 double-quote to start field name 와 같은 에러가 났다.

org.codehaus.jackson.JsonParseException: 
   Unexpected character ('t' (code 110)): was expecting double-quote to start field name
   at [Source: java.io.StringReader@7c87c24a; line: 1, column: 3]

이 에러를 보고 처음에는 이해가 안됐다. ""로 json 파일에 문자열을 처리가 잘됐고, 애초에 난 GCS에서 받은 파일을 일체 수정하지 않았다. 그런데 혹시나 해서 docker 내부에 들어가서 app.jar를 unzip하고(명령어: jar xvf 파일명.jar), vim으로 json 파일을 보려고 했다.

그래서 vim으로 열어 보니 아니 왠걸 ""로 감싸져야할 문자열이 다 ""이 풀려있다..
내 생각에는 github action 자체가 cp 하는 과정에서 ""를 다 떼버리는 것 같다.(아래처럼)

bash-4.4# cat optimum-lodge-404608-6839867a982a.json
{
type: service_account,
project_id: opti608,
private_key_id: 6839867a98af44a31fc6e8bdf,
private_key: -----BEGIN PRIVATE KEY-----FnLzsIkX7FaKj56Ri7EhZ+apPFCiM4lgnIlYDA7+Dnrp4pi3FjKxort0=n-----END PRIVATE KEY-----n,
client_email: springbootaccess@optimum608.iam.gserviceaccount.com,
client_id: 11604355,
auth_uri: 
token_uri
auth_provider_x509_cert_url: 
client_x509_cert_url: 
universe_domain: googleapis.com
}

그래서 어떻게 하면 ""을 유지할까 하다가 생각한게, base 64로 인코딩 된 문자열을 secrete으로 등록하고 cicd 돌때, 디코딩해주는 방법으로 구현하니 해결이 잘 됐다.(해당 코드는 위의 깃 레포에서 확인 가능하다.)


이렇게 만난 에러를 정리해봤다.
사실 더 많은데 이게 좀 핵심적 오류같다.

이번 계기로 위치 기반 서비스도 많이 고민해봤고, GCP도 어느정도 사용할 수 있게 됐다.
프론트도 공부해보고 좀 더 성장해서 다음 대회 수상을 기약해보자..!

profile
Backend Developer

0개의 댓글