springhazelcast

What this exception exactly came from? and how to remove it?


I have little question with spring cacheable. and hazelcast. really simple settings not embedded, but client.

I start hazelcast in local, use 'hz start' and, in spring,

@Bean('cacheManager')
  @Primary
  public HazelcastCacheManager cacheManager() {
    Properties props = new Properties();

    ClientConfig clientConfig = new ClientConfig();
    clientConfig.getNetworkConfig().addAddress(secondCacheHost);
    clientConfig.setInstanceName('2nd-cache');
    clientConfig.setProperties(props);

    HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig);
    return new HazelcastCacheManager(client);
  }

  @Bean('cache')
  public org.springframework.cache.Cache getCache() {
    return cacheManager().getCache(secondCacheName);
  }

  @Bean
  public CacheResolver cacheResolver() {
    return new CorrettoCacheResolver(getCache());
  }

i just simple controller for test. return nothing.

@Cacheable(cacheResolver = 'cacheResolver', value = 'data-cached')

it looks, works. but, always exception periodically.

심각: 2nd-cache [dev] [5.5.0] 2nd-cache.event-1 caught an exception while processing:com.hazelcast.client.impl.spi.impl.listener.ClientListenerServiceImplLambda2125/0x00007f9300c575b849ba4656
java.lang.NoClassDefFoundError: com/hazelcast/client/impl/clientside/SubsetMembers
    at com.hazelcast.client.impl.spi.impl.ClientClusterServiceImpl.getSubsetMembers(ClientClusterServiceImpl.java:329)
    at com.hazelcast.client.impl.spi.impl.listener.ClientClusterViewListenerServiceClusterViewListenerHandler.handleMemberGroupsViewEvent(ClientClusterViewListenerService.java:104)
    at com.hazelcast.client.impl.protocol.codec.ClientAddClusterViewListenerCodecAbstractEventHandler.handle(ClientAddClusterViewListenerCodec.java:162)
    at com.hazelcast.client.impl.spi.impl.listener.ClientClusterViewListenerServiceClusterViewListenerHandler.handle(ClientClusterViewListenerService.java:68)
    at com.hazelcast.client.impl.spi.impl.listener.ClientListenerServiceImpl.handleEventMessageOnCallingThread(ClientListenerServiceImpl.java:215)
    at com.hazelcast.client.impl.spi.impl.listener.ClientListenerServiceImpl.lambdahandleEventMessage3(ClientListenerServiceImpl.java:193)
    at com.hazelcast.internal.util.executor.StripedExecutorWorker.process(StripedExecutor.java:244)
    at com.hazelcast.internal.util.executor.StripedExecutorWorker.run(StripedExecutor.java:227)
Caused by: java.lang.ClassNotFoundException: 불허되는 접근: 이 웹 애플리케이션 인스턴스는 이미 중지되었습니다. [com.hazelcast.client.impl.clientside.SubsetMembers]을(를) 로드할 수 없습니다. 디버그 목적 및 불허되는 접근을 발생시킨 해당 Thread를 종료시키기 위한 시도로서, 다음 스택 트레이스가 생성됩니다.

what is this exception come from exactly?


Solution

  • I resolved with helped by hazelcast's slack.

    below is the solution. thanks Jaromir Hamala.

    ---------------------------------------------------------------------

    is this happening during the application shutdown? It looks to me (and Google Translator:)) like the app is shutting down and a classloader does not allow loading of new classes during shutdown. Some application servers/framework might behave like this.
    Hazelcast client is still running and processing events even while the application is shutting down and it needs to load a new class for some reason. You can try to shutdown the client too, perhaps something like this (just a guess):

    
    @Bean(destroyMethod = "shutdown")
    public HazelcastInstance hazelcastClient() {
        Properties props = new Properties();
        ClientConfig clientConfig = new ClientConfig();
        clientConfig.getNetworkConfig().addAddress(secondCacheHost);
        clientConfig.setInstanceName("2nd-cache");
        clientConfig.setProperties(props);
        return HazelcastClient.newHazelcastClient(clientConfig);
    }
    
    @Bean("cacheManager")
    @Primary
    public HazelcastCacheManager cacheManager(HazelcastInstance hazelcastClient) {
        return new HazelcastCacheManager(hazelcastClient);
    }
    [... the rest of your config ]