-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Could not initialize Hazelcast with a dependency on a JPA repository #15359
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
Comments
@JorgenRingen the contract with Spring Boot always has been that the cache infrastructure is available before the JPA entity manager kicks in. The main reasoning behind that is that if you don't do this and you use second level cache, Hibernate will attempt to initialize a cache manager and create a duplicate. Several things:
I don't see how we could support both use case and having the cache infrastructure initialized by the time hibernate starts (if you're using that) makes sense to me. Can't you defer the registration of the |
Okey, I see we should've avoided the cycle in the first place. Are there any preferable way of deferring the registration? As a first draft I'm doing a "lazy-lookup" from the ApplicationContext on the first call on FooRepository from FooMapStore, but it feels a bit awkward :-)
|
Thanks for the feedback. That's not really what I have in mind. I was more thinking about retrieving the |
I thought about registering the MapStore in a BeanPostProcessor, but according to com.hazelcast.config.Config The creation of the HazelcastInstance bean instantiates it ( |
@JorgenRingen that's not what this issue indicates. I've tried and got another Hazelcast problem that I don't really understand:
I've submitted a PR to your repro project. |
Interesting. This error only occurs when the mapstore is added in the postconstruct. As far as I understand hazelcast does some kind of broadcasting of the config if the config is updated after initialisation and thats what causing the serialization issue. From stacktrace:
Notice "broadcastConfigurationAsync". I'll try to experiment with the deferred registration in the application where the problem originally occurred a bit later. My example-app is over-simplified with regards to hazelcast in order to show the circular reference problem. Might have to do some additional configuration somewhere in order to do updates of the hazelcast-config after hazelcast initialization. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I have a similar issue. I want to initialize the Hazelcast Config with one setting from my database, which then I'm hit with the cyclical issue. |
Any updates on this? I'm facing a similar issue |
Uh oh!
There was an error while loading. Please reload this page.
Issue after upgrading from version 2.0.4 to 2.0.5+.
Startup fails with:
Caused by: org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'cacheManager': Requested bean is currently in creation: Is there an unresolvable circular reference?
I'm instantiating a HazelcastInstance bean manually and instantiation relies upon a org.springframework.data.jpa.repository.JpaRepository bean. This causes a circular reference on the cacheManager bean during initialisation.
I've debugged the dependency graph and it looks like this:
entityManagerFactory -> cacheManager -> JCacheCacheConfiguration -> hazelcastPropertiesCustomizer -> hazelcastInstance -> config -> fooMapStore -> fooRepository -> (inner bean)#hash -> entityManagerFactory -> cacheManager
Sample application: https://github.com/JorgenRingen/spring-boot-error-cachemanager-currently-in-creation
Any suggestions for workarounds?
The text was updated successfully, but these errors were encountered: