ehcache Management and Monitoring class not found NmsAgentEntity

209 views
Skip to first unread message

Nadeem Amin

unread,
Dec 18, 2017, 2:37:14 PM12/18/17
to ehcache-users
  1. version o
  2.  jdk 1.8

i am using  Ehcache : 3.4.0  tool kit   ,  and trying to setup mgmt and monitoring using the sample code. The sample code for mgmt and monitoring of ehcache results in classnotfound error. 
the NmsAgentEntity class is no where to be found. according to a developer , i  am missing Terracotta platform client jar .  but don't know where is this jar ?



primary used in the class :
https://github.com/ehcache/ehcache3/blob/2b3cf5da4480f8a74d903c1d112591a4844347e1/management/src/main/java/org/ehcache/management/cluster/DefaultClusteringManagementService.java

stacktrace

gov.cbp.ace.st.common.cache.ClusteredCacheManagerTest.testTvsClusteredCacheManager(ClusteredCacheManagerTest.java:54)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke(Method.java:507)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:121)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.lang.ClassNotFoundException: org.terracotta.management.entity.nms.agent.client.NmsAgentEntity
at java.net.URLClassLoader.findClass(URLClassLoader.java:607)
at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:844)
at java.lang.ClassLoader.loadClass(ClassLoader.java:823)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:325)
at java.lang.ClassLoader.loadClass(ClassLoader.java:803)
... 26 more

sample code

DefaultManagementRegistryConfiguration registryConfiguration = new DefaultManagementRegistryConfiguration().setCacheManagerAlias("myCacheManager1");
ManagementRegistryService managementRegistry = new DefaultManagementRegistryService(registryConfiguration);

CacheConfiguration<Long, String> cacheConfiguration = CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,
ResourcePoolsBuilder.newResourcePoolsBuilder().heap(1, MemoryUnit.MB).offheap(2, MemoryUnit.MB))
.build();

cacheManager = CacheManagerBuilder.newCacheManagerBuilder()
.withCache("myCache", cacheConfiguration)
.using(managementRegistry)
.build(true);

 
Contribut

Anthony Dahanne

unread,
Dec 18, 2017, 2:53:53 PM12/18/17
to ehcache-users
Hello Nadeem,
Can you give us the exact the URL of the kit you downloaded and used ?
Can you show to us your exact classpath ? (if you run from your IDE, try to get us the exact java -jar invocation)
Thanks

Nadeem Amin

unread,
Dec 19, 2017, 7:30:48 AM12/19/17
to ehcache-users

Henri Tremblay

unread,
Dec 19, 2017, 10:00:22 AM12/19/17
to ehcach...@googlegroups.com
And where have you found DefaultManagementRegistryConfiguration?

--
You received this message because you are subscribed to the Google Groups "ehcache-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ehcache-users+unsubscribe@googlegroups.com.
To post to this group, send email to ehcach...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ehcache-users/d9b17b00-4a62-43df-9f8b-ea140e7553fe%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Anthony Dahanne

unread,
Dec 19, 2017, 12:38:45 PM12/19/17
to ehcache-users
Hello Nadeem,
There is no public stats API yet.
You may want to star this issue : https://github.com/ehcache/ehcache3/issues/1940 

Meanwhile, have a look at this example, it should help you out :


Anthony

Nadeem Amin

unread,
Dec 20, 2017, 8:24:14 AM12/20/17
to ehcache-users

the sample code works fine but when i switch to the  terracotta  based cache config, i still get class not found error .  i have both jars in the path.  




init code :
managementRegistry = new DefaultManagementRegistryService(
new DefaultManagementRegistryConfiguration().setCacheManagerAlias(poolType.name())
  .addTags("caching", "client"));


CacheManagerBuilder<PersistentCacheManager> clusteredCacheManagerBuilder = newCacheManagerBuilder()
.using(managementRegistry)
.with(cluster(URI.create(url))
.readOperationTimeout(2, TimeUnit.SECONDS)
.autoCreate())
.withCache(poolType.name(),
newCacheConfigurationBuilder(keyType, CacheContainer.class,
ResourcePoolsBuilder.newResourcePoolsBuilder()
.heap(1, EntryUnit.ENTRIES)
.offheap(1, MemoryUnit.MB)  
.with(clusteredDedicated("primary-server-resource", 2, MemoryUnit.MB)))
.add(new ClusteredStoreConfiguration(Consistency.EVENTUAL)));


print code :
Context context = Context.empty()
.with("cacheManagerName", poolType.name())
         .with("cacheName", poolType.name());

ContextualStatistics statistics1 = managementRegistry.withCapability("StatisticsCapability")
.queryAllStatistics().on(context).build().execute().getResult(context);
logger.info("Statistics : " + poolType.name() + ":::" + new TreeMap(statistics1.getStatistics()).toString());




ERROR Message

08:17:36.358 [Connection Maker - 3e91d28118d2464fbed55e965185aa4c] INFO  com.tc.object.DistributedObjectClient - Connection successfully established to server at xxxx:8090
Error occured in testing :org/terracotta/management/entity/nms/agent/client/NmsAgentEntity
java.lang.NoClassDefFoundError: org/terracotta/management/entity/nms/agent/client/NmsAgentEntity
at org.ehcache.management.cluster.DefaultClusteringManagementService.start(DefaultClusteringManagementService.java:89)
at org.ehcache.management.registry.DefaultManagementRegistryService.start(DefaultManagementRegistryService.java:82)
at org.ehcache.core.internal.service.ServiceLocator.startAllServices(ServiceLocator.java:118)
at org.ehcache.core.EhcacheManager.init(EhcacheManager.java:560)
at org.ehcache.config.builders.CacheManagerBuilder.build(CacheManagerBuilder.java:72)
at gov.cbp.ace.st.common.cache.ClusteredCacheManager.init(ClusteredCacheManager.java:216)
at gov.cbp.ace.st.common.cache.ClusteredCacheManager.getCache(ClusteredCacheManager.java:142)
at gov.cbp.ace.st.common.cache.ClusteredCacheManager.saveValue(ClusteredCacheManager.java:306)
at gov.cbp.ace.st.common.cache.ClusteredCacheManager.saveValue(ClusteredCacheManager.java:323)
at gov.cbp.ace.st.common.cache.ClusteredCacheManager.monitorCache(ClusteredCacheManager.java:343)
at gov.cbp.ace.st.common.cache.ClusteredCacheManagerTest.testMOnitorClusteredCacheManager(ClusteredCacheManagerTest.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke(Method.java:507)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:86)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

To unsubscribe from this group and stop receiving emails from it, send an email to ehcache-user...@googlegroups.com.

To post to this group, send email to ehcach...@googlegroups.com.

Anthony Dahanne

unread,
Dec 20, 2017, 10:19:52 PM12/20/17
to ehcache-users
Hello Nadeem,
True, it's bit different with clustered and the monitoring stack.
You need to do 2 things :
* add the jar named mnm-nms-agent to your client classpath
* add the jar named mnm-server.jar to your server/plugins/lib server folder

And it should work
I have updated the github project with the jar coordinates


REMEMBER : it's not official API, things can break and change anytime, please watch https://github.com/ehcache/ehcache3/issues/1940 

Nadeem Amin

unread,
Dec 21, 2017, 9:39:09 AM12/21/17
to ehcache-users
Greatly Appreciate your response and effort to help me get this done.  This works perfectly 

Happy Holidays !!
Nadeem
Reply all
Reply to author
Forward
0 new messages