问题
I am trying to make a small Hazelcast cluster cooperate with simple JCache compliant client. Unfortunately, I get the exception: "java.lang.IllegalArgumentException: No service registered with name: hz:impl:cacheService". I would appreciate a clue how to fix that.
I am using version 3.4 of Hazelcast (got the same behavior with 3.3 and 3.4-EA).
Here is a snippet from hazelcast-client.xml:
<group>
<name>group1</name>
</group>
<network>
<cluster-members>
<address>192.168.56.10:5701</address>
<address>192.168.56.20:5701</address>
</cluster-members>
</network>
The log from the Hazelcast cluster node:
Dec 30, 2014 9:21:06 AM com.hazelcast.config.XmlConfigLocator
INFO: Loading configuration /vagrant/resources/hazelcast.xml from System property 'hazelcast.config'
Dec 30, 2014 9:21:06 AM com.hazelcast.config.XmlConfigLocator
INFO: Using configuration file at /vagrant/resources/hazelcast.xml
Dec 30, 2014 9:21:07 AM com.hazelcast.instance.DefaultAddressPicker
INFO: [LOCAL] [group1] [3.4] Prefer IPv4 stack is true.
Dec 30, 2014 9:21:07 AM com.hazelcast.instance.DefaultAddressPicker
INFO: [LOCAL] [group1] [3.4] Picked Address[192.168.56.10]:5701, using socket ServerSocket[addr=/0:0:0:0:0:0:0:0,localport=5701], bind any local is true
Dec 30, 2014 9:21:08 AM com.hazelcast.spi.OperationService
INFO: [192.168.56.10]:5701 [group1] [3.4] Backpressure is disabled
Dec 30, 2014 9:21:08 AM com.hazelcast.spi.impl.BasicOperationScheduler
INFO: [192.168.56.10]:5701 [group1] [3.4] Starting with 2 generic operation threads and 2 partition operation threads.
Dec 30, 2014 9:21:08 AM com.hazelcast.system
INFO: [192.168.56.10]:5701 [group1] [3.4] Hazelcast 3.4 (20141224 - 3dc5214) starting at Address[192.168.56.10]:5701
Dec 30, 2014 9:21:08 AM com.hazelcast.system
INFO: [192.168.56.10]:5701 [group1] [3.4] Copyright (C) 2008-2014 Hazelcast.com
Dec 30, 2014 9:21:08 AM com.hazelcast.instance.Node
INFO: [192.168.56.10]:5701 [group1] [3.4] Creating MulticastJoiner
Dec 30, 2014 9:21:08 AM com.hazelcast.core.LifecycleService
INFO: [192.168.56.10]:5701 [group1] [3.4] Address[192.168.56.10]:5701 is STARTING
Dec 30, 2014 9:21:14 AM com.hazelcast.cluster.impl.MulticastJoiner
INFO: [192.168.56.10]:5701 [group1] [3.4] Trying to join to discovered node: Address[192.168.56.20]:5701
Dec 30, 2014 9:21:14 AM com.hazelcast.nio.tcp.SocketConnector
INFO: [192.168.56.10]:5701 [group1] [3.4] Connecting to /192.168.56.20:5701, timeout: 0, bind-any: true
Dec 30, 2014 9:21:14 AM com.hazelcast.nio.tcp.TcpIpConnectionManager
INFO: [192.168.56.10]:5701 [group1] [3.4] Established socket connection between /192.168.56.10:50374 and 192.168.56.20/192.168.56.20:5701
Dec 30, 2014 9:21:20 AM com.hazelcast.cluster.ClusterService
INFO: [192.168.56.10]:5701 [group1] [3.4]
Members [2] {
Member [192.168.56.20]:5701
Member [192.168.56.10]:5701 this
}
Dec 30, 2014 9:21:22 AM com.hazelcast.core.LifecycleService
INFO: [192.168.56.10]:5701 [group1] [3.4] Address[192.168.56.10]:5701 is STARTED
Dec 30, 2014 9:22:17 AM com.hazelcast.nio.tcp.SocketAcceptor
INFO: [192.168.56.10]:5701 [group1] [3.4] Accepting socket connection from /192.168.56.1:39715
Dec 30, 2014 9:22:17 AM com.hazelcast.nio.tcp.TcpIpConnectionManager
INFO: [192.168.56.10]:5701 [group1] [3.4] Established socket connection between /192.168.56.10:5701 and 192.168.56.1/192.168.56.1:39715
Dec 30, 2014 9:22:17 AM com.hazelcast.client.impl.client.AuthenticationRequest
INFO: [192.168.56.10]:5701 [group1] [3.4] Received auth from Connection [/192.168.56.10:5701 -> 192.168.56.1/192.168.56.1:39715], endpoint=null, live=true, type=JAVA_CLIENT, successfully authenticated
Dec 30, 2014 9:22:17 AM com.hazelcast.client.ClientEngine
SEVERE: [192.168.56.10]:5701 [group1] [3.4] While executing request: com.hazelcast.client.impl.client.ClientCreateRequest@1256d778 -> No service registered with name: hz:impl:cacheService
java.lang.IllegalArgumentException: No service registered with name: hz:impl:cacheService
at com.hazelcast.client.impl.ClientEngineImpl$ClientPacketProcessor.initService(ClientEngineImpl.java:477)
at com.hazelcast.client.impl.ClientEngineImpl$ClientPacketProcessor.processRequest(ClientEngineImpl.java:427)
at com.hazelcast.client.impl.ClientEngineImpl$ClientPacketProcessor.run(ClientEngineImpl.java:353)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at com.hazelcast.util.executor.HazelcastManagedThread.executeRun(HazelcastManagedThread.java:76)
at com.hazelcast.util.executor.HazelcastManagedThread.run(HazelcastManagedThread.java:92)
And below is the log from the client:
Dec 30, 2014 10:22:16 AM com.hazelcast.client.config.XmlClientConfigLocator
INFO: Loading 'hazelcast-client.xml' from classpath.
Dec 30, 2014 10:22:17 AM com.hazelcast.core.LifecycleService
INFO: HazelcastClient[hz.client_0_group1][3.4] is STARTING
Dec 30, 2014 10:22:17 AM com.hazelcast.core.LifecycleService
INFO: HazelcastClient[hz.client_0_group1][3.4] is STARTED
Dec 30, 2014 10:22:17 AM com.hazelcast.core.LifecycleService
INFO: HazelcastClient[hz.client_0_group1][3.4] is CLIENT_CONNECTED
Dec 30, 2014 10:22:17 AM com.hazelcast.client.spi.impl.ClusterListenerThread
INFO:
Members [2] {
Member [192.168.56.20]:5701
Member [192.168.56.10]:5701
}
Exception in thread "main" javax.cache.CacheException: Error opening URI [hazelcast]
at com.hazelcast.cache.impl.AbstractHazelcastCachingProvider.getCacheManager(AbstractHazelcastCachingProvider.java:89)
at com.hazelcast.cache.impl.AbstractHazelcastCachingProvider.getCacheManager(AbstractHazelcastCachingProvider.java:118)
at com.hazelcast.cache.HazelcastCachingProvider.getCacheManager(HazelcastCachingProvider.java:158)
at com.example.JCacheSample.main(JCacheSample.java:16)
Caused by: java.lang.IllegalArgumentException: No service registered with name: hz:impl:cacheService
at com.hazelcast.client.impl.ClientEngineImpl$ClientPacketProcessor.initService(ClientEngineImpl.java:477)
at com.hazelcast.client.impl.ClientEngineImpl$ClientPacketProcessor.processRequest(ClientEngineImpl.java:427)
at com.hazelcast.client.impl.ClientEngineImpl$ClientPacketProcessor.run(ClientEngineImpl.java:353)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at com.hazelcast.util.executor.HazelcastManagedThread.executeRun(HazelcastManagedThread.java:76)
at com.hazelcast.util.executor.HazelcastManagedThread.run(HazelcastManagedThread.java:92)
at ------ End remote and begin local stack-trace ------.(Unknown Source)
at com.hazelcast.client.spi.impl.ClientCallFuture.resolveResponse(ClientCallFuture.java:201)
at com.hazelcast.client.spi.impl.ClientCallFuture.get(ClientCallFuture.java:142)
at com.hazelcast.client.spi.impl.ClientCallFuture.get(ClientCallFuture.java:118)
at com.hazelcast.client.spi.ProxyManager.initialize(ProxyManager.java:200)
at com.hazelcast.client.spi.ProxyManager.getOrCreateProxy(ProxyManager.java:183)
at com.hazelcast.client.impl.HazelcastClientInstanceImpl.getDistributedObject(HazelcastClientInstanceImpl.java:391)
at com.hazelcast.client.impl.HazelcastClientProxy.getDistributedObject(HazelcastClientProxy.java:234)
at com.hazelcast.client.cache.impl.HazelcastClientCacheManager.<init>(HazelcastClientCacheManager.java:62)
at com.hazelcast.client.cache.impl.HazelcastClientCachingProvider.createHazelcastCacheManager(HazelcastClientCachingProvider.java:75)
at com.hazelcast.client.cache.impl.HazelcastClientCachingProvider.createHazelcastCacheManager(HazelcastClientCachingProvider.java:38)
at com.hazelcast.cache.impl.AbstractHazelcastCachingProvider.getCacheManager(AbstractHazelcastCachingProvider.java:86)
... 3 more
回答1:
Activated JCache on serverside as well? :)
All is needed is to add cache-api-1.0.0.jar to Hazelcast node's classpath.
回答2:
I got the same error message in an OSGi context. cache-api was on the classpath (I head to use 'org.apache.servicemix.bundles:org.apache.servicemix.bundles.javax-cache-api:1.0.0_1'
, because of missing exports in the other lib).
The problem was, the wrong ClassLoader was used to check if JCache was on the classpath. Therefore I had to initialize the Hazelcast Instance like this:
ClassLoader hazelClassLoader = hazelcastOSGiService.getOwnerBundle().adapt(BundleWiring.class).getClassLoader();
Config config = new Config();
// set the classloader that is used by hazelcast to check for JCache Classes
config.setClassLoader(hazelClassLoader);
// Create a HazelcastInstance
hazelcastInstance = hazelcastOSGiService.newHazelcastInstance(config);
来源:https://stackoverflow.com/questions/27703342/exception-while-trying-to-make-hazelcast-cluster-work-with-jcache-compliant-clie