question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bucket4j + Hazelcast ClassNotFoundException

See original GitHub issue

I am trying to use the bucket4j with Hazelcast, but the follow exception is throw:

mar 13, 2018 11:24:27 AM com.hazelcast.core.LifecycleService INFORMAÇÕES: hz.client_0 [dev] [3.9.3] HazelcastClient 3.9.3 (20180216 - 539b124) is STARTING mar 13, 2018 11:24:27 AM com.hazelcast.core.LifecycleService INFORMAÇÕES: hz.client_0 [dev] [3.9.3] HazelcastClient 3.9.3 (20180216 - 539b124) is STARTED mar 13, 2018 11:24:28 AM com.hazelcast.client.connection.ClientConnectionManager INFORMAÇÕES: hz.client_0 [dev] [3.9.3] Trying to connect to [localhost]:5701 as owner member mar 13, 2018 11:24:28 AM com.hazelcast.client.connection.ClientConnectionManager INFORMAÇÕES: hz.client_0 [dev] [3.9.3] Authenticated with server [127.0.0.1]:5701, server version:3.7.5 Local address: /127.0.0.1:50624 mar 13, 2018 11:24:28 AM com.hazelcast.client.spi.impl.ClientMembershipListener INFORMAÇÕES: hz.client_0 [dev] [3.9.3]

Members [1] { Member [127.0.0.1]:5701 - f37ba1b2-7b20-4b6d-83ac-8e6f4f79a4d8 }

mar 13, 2018 11:24:28 AM com.hazelcast.client.connection.ClientConnectionManager INFORMAÇÕES: hz.client_0 [dev] [3.9.3] Setting ClientConnection{alive=true, connectionId=1, channel=NioChannel{/127.0.0.1:50624->localhost/127.0.0.1:5701}, remoteEndpoint=[127.0.0.1]:5701, lastReadTime=2018-03-13 11:24:28.062, lastWriteTime=2018-03-13 11:24:28.059, closedTime=never, lastHeartbeatRequested=never, lastHeartbeatReceived=never, connected server version=3.7.5} as owner with principal ClientPrincipal{uuid=‘e27ac329-05f0-474b-b8d8-7295009cc862’, ownerUuid=‘f37ba1b2-7b20-4b6d-83ac-8e6f4f79a4d8’} mar 13, 2018 11:24:28 AM com.hazelcast.core.LifecycleService INFORMAÇÕES: hz.client_0 [dev] [3.9.3] HazelcastClient 3.9.3 (20180216 - 539b124) is CLIENT_CONNECTED mar 13, 2018 11:24:28 AM com.hazelcast.internal.diagnostics.Diagnostics INFORMAÇÕES: hz.client_0 [dev] [3.9.3] Diagnostics disabled. To enable add -Dhazelcast.diagnostics.enabled=true to the JVM arguments. Exception in thread “main” com.hazelcast.nio.serialization.HazelcastSerializationException: java.lang.ClassNotFoundException: io.github.bucket4j.grid.hazelcast.HazelcastEntryProcessorAdapter at com.hazelcast.internal.serialization.impl.JavaDefaultSerializers$JavaSerializer.read(JavaDefaultSerializers.java:224) at com.hazelcast.internal.serialization.impl.StreamSerializerAdapter.read(StreamSerializerAdapter.java:48) at com.hazelcast.internal.serialization.impl.AbstractSerializationService.toObject(AbstractSerializationService.java:172) at com.hazelcast.client.impl.protocol.task.map.MapExecuteOnKeyMessageTask.prepareOperation(MapExecuteOnKeyMessageTask.java:42) at com.hazelcast.client.impl.protocol.task.AbstractPartitionMessageTask.processMessage(AbstractPartitionMessageTask.java:62) at com.hazelcast.client.impl.protocol.task.AbstractMessageTask.initializeAndProcessMessage(AbstractMessageTask.java:128) at com.hazelcast.client.impl.protocol.task.AbstractMessageTask.run(AbstractMessageTask.java:108) at com.hazelcast.spi.impl.operationservice.impl.OperationRunnerImpl.run(OperationRunnerImpl.java:137) at com.hazelcast.spi.impl.operationexecutor.impl.OperationThread.process(OperationThread.java:127) at com.hazelcast.spi.impl.operationexecutor.impl.OperationThread.run(OperationThread.java:102) at ------ submitted from ------.(Unknown Source) at com.hazelcast.client.spi.impl.ClientInvocationFuture.resolveAndThrowIfException(ClientInvocationFuture.java:96) at com.hazelcast.client.spi.impl.ClientInvocationFuture.resolveAndThrowIfException(ClientInvocationFuture.java:33) at com.hazelcast.spi.impl.AbstractInvocationFuture.get(AbstractInvocationFuture.java:155) at com.hazelcast.client.spi.ClientProxy.invokeOnPartition(ClientProxy.java:204) at com.hazelcast.client.spi.ClientProxy.invoke(ClientProxy.java:198) at com.hazelcast.client.proxy.ClientMapProxy.executeOnKeyInternal(ClientMapProxy.java:1294) at com.hazelcast.client.proxy.ClientMapProxy.executeOnKey(ClientMapProxy.java:1287) at io.github.bucket4j.grid.hazelcast.HazelcastProxy.createInitialState(HazelcastProxy.java:52) at io.github.bucket4j.grid.GridBucket.<init>(GridBucket.java:56) at io.github.bucket4j.grid.GridBucket.createInitializedBucket(GridBucket.java:43) at io.github.bucket4j.grid.hazelcast.HazelcastBucketBuilder.build(HazelcastBucketBuilder.java:57) at luankevinferreira.Bucket4jHazelcast.main(Bucket4jHazelcast.java:34) Caused by: java.lang.ClassNotFoundException at com.hazelcast.client.impl.protocol.ClientExceptionFactory$12.createException(ClientExceptionFactory.java:203) at com.hazelcast.client.impl.protocol.ClientExceptionFactory.createException(ClientExceptionFactory.java:744) at com.hazelcast.client.impl.protocol.ClientExceptionFactory.createException(ClientExceptionFactory.java:690) at com.hazelcast.client.spi.impl.AbstractClientInvocationService$ResponseThread.handleClientMessage(AbstractClientInvocationService.java:319) at com.hazelcast.client.spi.impl.AbstractClientInvocationService$ResponseThread.process(AbstractClientInvocationService.java:302) at com.hazelcast.client.spi.impl.AbstractClientInvocationService$ResponseThread.doRun(AbstractClientInvocationService.java:295) at com.hazelcast.client.spi.impl.AbstractClientInvocationService$ResponseThread.run(AbstractClientInvocationService.java:279)

My code is just like this:

public class Bucket4jHazelcast {

    /**
     * @param args
     */
    public static void main(String[] args) {
        ClientConfig clientConfig = new ClientConfig();
        clientConfig.getNetworkConfig().addAddress("localhost");
        HazelcastInstance instance = HazelcastClient.newHazelcastClient(clientConfig);

        Bucket bucket = Bucket4j.extension(Hazelcast.class).builder()//
                .addLimit(Bandwidth.simple(10, Duration.ofMinutes(1)))//
                .build(instance.getMap("test"), "test", RecoveryStrategy.RECONSTRUCT);

        bucket.tryConsume(1);
    }

}

Can you help me?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
vladimir-bukhtoyarovcommented, Mar 13, 2018

I never seen before the HazelcastInstance, looks like it has been introduced within Hazelcast 3.9. Based on common sense I suppose that you are trying to connect as ligh-weight client to the another hazelcast server node. If I am right then check that following jars present in classpath of the Hazelcast server node:

  • bucket4j-core
  • bucket4j-jcache
  • bucket4j-hazelcast

These jars should present on both client and server nodes.

0reactions
luankevinferreiracommented, Mar 14, 2018

Thanks a lot, it works!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bucket4j + Hazelcast ClassNotFoundException #66 - GitHub
I am trying to use the bucket4j with Hazelcast, but the follow exception is throw: mar 13, 2018 11:24:27 AM com.hazelcast.core.
Read more >
HazelcastSerializationException with Hazelcast 4.2 and ...
I have upgraded my Hazelcast and bucket 4j. And now I have error com.hazelcast.nio.serialization.HazelcastSerializationException: java.lang.
Read more >
vladimir-bukhtoyarov/bucket4j - Gitter
I got this exception: com.hazelcast.nio.serialization.HazelcastSerializationException: java.lang.ClassNotFoundException: io.github.bucket4j.grid.hazelcast.
Read more >
java.lang.ClassNotFoundException for MapLoader configured ...
I am using multi node hazelcast (3.11 version) cluster. My use case is, during hazelcast startup, I want each member to load the...
Read more >
bucket4j - Bountysource
bucket4j. Java implementation of token-bucket algorithm for rate-limiting ... ClassNotFoundException: io.github.bucket4j.grid.hazelcast.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found