Skip to content
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

Improve exception message in case of incomplete Caching configuration. [SPR-12898] #17497

Closed
spring-issuemaster opened this issue Apr 8, 2015 · 3 comments

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

commented Apr 8, 2015

Thomas Darimont opened SPR-12898 and commented

If a user declares multiple CacheManager's without declaring one of them as @Primary and without using a CacheResolver the following Exception is thrown during bootstrap:

java.lang.IllegalStateException: No CacheResolver specified, and no unique bean of type CacheManager found. Mark one as primary or declare a specific CacheManager to use.

In the linked example gist I had two CacheManager's and a Service with two operations where each operation was explicitly referring to a CacheManager. So from looking at the code it seemed that everything was setup correctly.

We should enhance the exception message to make clear that a CacheManager needs to be the "default" one in case no additional configuration is present etc.

How about:

No CacheResolver specified, and no unique bean of type CacheManager found. Mark one as primary (or give it the name cacheManager) or declare a specific CacheManager to use, that serves as the default one.

Affects: 4.1.6

Reference URL: https://gist.github.com/thomasdarimont/b855ae97708d4d8c3c1f

Referenced from: commits e5b5052

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Apr 8, 2015

Prashant Deva commented

??Mark one as primary??
should be
Mark one as @Primary.
the docs dont say anything about how to mark cache as primary

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Apr 8, 2015

Oliver Drotbohm commented

#11960 is the ticket for that aspect. However, I think the exception message should stay open in the actual means of marking one bean as the primary as simply naming one of the beans cacheManager should work as well. This is consistent to the disambiguation approaches in the transaction subsystem where a bean named transactionManager is always considered the primary one.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Apr 10, 2015

Stéphane Nicoll commented

Thanks for the proposal, guys!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.