원인모를 LazyInitializationException - no Session
2020. 5. 25. 15:14ㆍplming/Java-Spring Boot
@Entity Class의 property에서
다른 @Entity Class를 참조하며
@ManyToOne(fetch = FetchType.LAZY) 를 주었다면
해당 property로 접근하려고 할 때는...?
뭐 다른 일이 일어날게 없다... ㅡㅡ;;;
뭐 흔하게 계~~~속 잘~~~ 써 왔던 경우인데...
어느 날 갑자기, 뜬금없이, 아무리 생각해도 이해를 하지 못할...
아래처럼 LazyInitializationException 이 나왔다면...
org.hibernate.LazyInitializationException: could not initialize proxy [common.model.entity.P#2915] - no Session
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:155)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:268)
at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:73)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:746)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:62)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)
at sun.reflect.GeneratedMethodAccessor180.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84)
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
혹시... 해당 Class에서
@Scheduled 를 사용하고 있지 않은가?
그렇다면
@Scheduled 를 사용하는 Class와
Entity를 처리하는 Class를 분리해야 한다.
org.springframework.boot 2.0.8
spring-context 5.0.12
이 환경에서는 분리하니...
언제 그랬냐는 듯이...
잘 돌아간다...;;;
이런 경우는...
정말 만나고 싶지 않아...
'plming > Java-Spring Boot' 카테고리의 다른 글
프롤로그에서는 콘텐츠가 허용되지 않습니다. (0) | 2023.12.20 |
---|---|
Apache + SpringBoot 연동 (0) | 2023.10.19 |
IntelliJ에서 실행시 build-info.properties 생성되지 않을 때 (0) | 2023.10.11 |
파일 Upload 크기 제한 설정 (0) | 2019.06.16 |