-
Notifications
You must be signed in to change notification settings - Fork 37.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cache setup failure does not provide nested cause #25250
Comments
The error message is intended to guide you as what the next steps are for this:
I don't really understand how the nested cause would have helped you. If you have multiple cache managers, you need to flag one as |
My means that the IllegalStateException not catched, so my project is also running but not have error log or other message, and the project is also can't do request, so can in class AbstractApplicationContext's method: refresh() can catch the same as IllegalStateException? |
I am not sure I understand what you mean by that. It must not be caught. It is supposed to fail hard and prevent your application to start as its configuration is incorrect. |
Yes,my application is incorrect, but the exception is not logged,so it's make me many hours to find the exception. If I can know the exception,I will quickly solve it. |
I don't see how the exception would not be logged. Can you please share a small sample that demonstrates the problem (either a zip attached to this issue or a link to a GitHub repo) |
Both options are provided, but having the nested cause is clearer. Having
means I start in CacheAspectSupport.afterSingletonsInstantiated and drill down to the real problem. Whereas if I'd have known
from the outset, it clarifies things a bit ("So that's why @Primary on the bean I want doesn't work") "Hours" is definitely an exaggeration in my case (10 minutes?), but the missing root cause did feel like enough of a "bug" that I searched for and found this issue. |
Your case is different, you have two beans marked as |
Thanks for take my advice, I think it's better than before. |
When the our spring-framework project is started, we defined multi CacheManager, but not set which is primary, then running the class AbstractApplicationContext.finishBeanFactoryInitialization, there is an IllegalStateException:
But it not catched, it only catched BeansException, then it will do the finally code, it will lose some key message to help find the issue.
It's hard to find the issue because the exception is not logged. So can spring catch the exception of IllegalStateException or RuntimeException?
It's solved by setting the primary CacheManager via
@Primary
.Code:org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization
There has exception code:
org.springframework.cache.interceptor.CacheAspectSupport.afterSingletonsInstantiated:
The text was updated successfully, but these errors were encountered: