I encountered a similar problem some time ago.
If you are using Spring DevTools or similar tool for hot reload, try disabling it. The main reason is, such tools might load classes with different class loaders on application reload.
Reference: https://docs.spring.io/spring-boot/reference/using/devtools.html#using.devtools.restart.restart-vs-reload.
Also, please share stack trace and program code using code blocks, as it would be easier to read to review it and provide support later.