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

Cannot override cache's CacheManager - after restart of remote Hazelcast #12975

exmortal opened this issue Apr 25, 2018 · 1 comment

Cannot override cache's CacheManager - after restart of remote Hazelcast #12975

exmortal opened this issue Apr 25, 2018 · 1 comment


Copy link

@exmortal exmortal commented Apr 25, 2018

Hi everyone,

I faced with Cannot override cache's CacheManager exception when I tried to recreate a cache instance after I restarted remote Hazelcast. Hazelcast client successfully reestablished connection, but... all cache instances already using in application are inactive now. Any attempts to touch it will throw:

com.hazelcast.cache.CacheNotExistsException: Cache /hz/cache1 is already destroyed or not created yet...

To avoid that I tried to recreate each cache instance using new cache manager, because previous was closed due lost connection. First attempt to create a cache fails with:

java.lang.IllegalStateException: Cannot overwrite a Cache's CacheManager.
	at com.hazelcast.client.cache.impl.AbstractClientInternalCacheProxy.setCacheManager( ~[hazelcast-client-3.9.3.jar:3.9.3]
	at com.hazelcast.client.cache.impl.ClientCacheProxy.setCacheManager( ~[hazelcast-client-3.9.3.jar:3.9.3]
	at com.hazelcast.client.cache.impl.HazelcastClientCacheManager.createCacheProxy( ~[hazelcast-client-3.9.3.jar:3.9.3]
	at com.hazelcast.cache.impl.AbstractHazelcastCacheManager.getCacheUnchecked( ~[hazelcast-3.9.3.jar:3.9.3]
	at com.hazelcast.cache.impl.AbstractHazelcastCacheManager.getCache( ~[hazelcast-3.9.3.jar:3.9.3]
	at com.hazelcast.cache.impl.AbstractHazelcastCacheManager.getCache( ~[hazelcast-3.9.3.jar:3.9.3]

My application uses JCache API to create caches, like this:

CachingProvider provider = Caching.getCachingProvider();
CacheManager manager = provider.getCacheManager();

Cache<K, V> cache = manager.getCache(cacheName);
if (cache != null) {
    return cache;
return manager.createCache(cacheName, configuration);       

This error happened because of this PR #11076
Any ideas how to invalidate all Cache instances on fly ? Or it's a bug ?


Copy link

@vbekiaris vbekiaris commented Jun 1, 2018

@exmortal thanks for the issue report. It is a bug and a fix PR (#13228) has been created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants
You can’t perform that action at this time.