Java client 2.0 + JSF 2.2 OperatingSystemMXBean error on connect to Cluster

trying a simple connection to Couchbase Server 3.0.0 from java-client 2.0 and 2.0.0-beta2 throws following error :

15:44:51,334 INFO  [com.couchbase.client.core.CouchbaseCore] (MSC service thread 1-9) CoreEnvironment: {sslEnabled=false, sslKeystoreFile='null', sslKeystorePassword='null', queryEnabled=false, queryPort=8093, bootstrapHttpEnabled=true, bootstrapCarrierEnabled=true, bootstrapHttpDirectPort=8091, bootstrapHttpSslPort=18091, bootstrapCarrierDirectPort=11210, bootstrapCarrierSslPort=11207, ioPoolSize=12, computationPoolSize=12, responseBufferSize=16384, requestBufferSize=16384, kvServiceEndpoints=1, viewServiceEndpoints=1, queryServiceEndpoints=1, ioPool=NioEventLoopGroup, coreScheduler=CoreScheduler, packageNameAndVersion=couchbase-java-client/2.0.0-beta2 (git: 2.0.0-beta2)}
15:44:51,335 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-9) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./: Failed to start service
	at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_55]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_55]
	at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_55]
Caused by: java.lang.NoClassDefFoundError: com/sun/management/OperatingSystemMXBean
	at com.couchbase.client.core.env.Diagnostics.systemInfo(Diagnostics.java:60)
	at com.couchbase.client.core.env.Diagnostics.collect(Diagnostics.java:132)
	at com.couchbase.client.core.env.Diagnostics.collectAndFormat(Diagnostics.java:147)
	at com.couchbase.client.core.CouchbaseCore.<init>(CouchbaseCore.java:139)
	at com.couchbase.client.java.CouchbaseAsyncCluster.<init>(CouchbaseAsyncCluster.java:92)
	at com.couchbase.client.java.CouchbaseCluster.<init>(CouchbaseCluster.java:61)
	at com.couchbase.client.java.CouchbaseCluster.create(CouchbaseCluster.java:41)
	at com.couchbase.client.java.CouchbaseCluster.create(CouchbaseCluster.java:37)
	at com.couchbase.client.java.CouchbaseCluster.create(CouchbaseCluster.java:29)
	at com.myproject.testproject.ApplicationContextListener.connectToCouchbase(ApplicationContextListener.java:35)
	at com.myproject.testproject.ApplicationContextListener.contextInitialized(ApplicationContextListener.java:24)
	at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:173)
	at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:190)
	at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:87)
	at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.start(UndertowDeploymentService.java:72)
	at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
	at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
	... 3 more
Caused by: java.lang.ClassNotFoundException: com.sun.management.OperatingSystemMXBean from [Module "deployment.TestProject-1.0-SNAPSHOT.war:main" from Service Module Loader]
	at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.3.Final]
	at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.3.Final]
	at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.3.Final]
	at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.3.Final]
	at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.3.Final]
	... 20 more

line 35 of ApplicationContextListener is :

Cluster cluster = CouchbaseCluster.create( );

any help appreciated.

Oh, this could be a bug we’ve not anticipated. It looks like the OperatingSystemMXBean is not available.

I’ve created a ticket to get this fixed (http://www.couchbase.com/issues/browse/JVMCBC-62)
But can you please tell us the OS and JVM you are using? I’m curious

Oh, this could be a bug we’ve not anticipated. It looks like the OperatingSystemMXBean is not available.

Can you tell us which JVM and app server you are using?
We need to get this more resilient, thanks for raising it (http://www.couchbase.com/issues/browse/JVMCBC-62)

OS X 10.9.4
java jdk1.7.0_55
wildfly-8.1.0.Final
java-client 2.0 and 2.0.0-beta2

thanks much, would it be possible that you share a code example on github or as a zip package here? Just something that I can run as a app on wildfly to verify a fix is working. Very much appreciated!

Nevermind, got it running on my own.

I’m glad to report that I’ve reproduced the issue and already fixed it on master. We have a 2.0.1 release due tomorrow, please grab this version and you should be good. If you find any other issues after that let me know as well.

cool. sounds good will do. thanks

2.0.1 is out already, please give it a shot @testingCbJava2

@daschl just finished migrating an entire JSF 2.2 app from couchbase-client 1.4.4 to couchbase java-client 2.0.1

everything is working, good stuff!

1 Like

@testingCbJava2 that is awesome to hear! Is it by chance open source so I can take a look? If not, I’d love to get in touch so I can take a look nevertheless, I want to learn more about how people are approaching the 2.0 SDK and close the feedback loop.

@daschl of course!
the classes used to handle everything to and from couchbase are opensource.
code at https://github.com/devstackio/DevStackIo

the main java-client 2+ files being :
com.devstackio.maven.couchbase.CbDao
//handles main connections (cluster / buckets)
com.devstackio.maven.couchbase.EntityCbDao
//anything that needs CRUD on couchbase extends…
and com.devstackio.maven.couchbase.ContractCbDao’s convert method, to demo how all extended classes should look

Great, thanks!

A few things of notice:

thanks alot!
new version updated

2.0.1.005
-CbDao
: initCluster method added to initialize single cluster connection
: addBucketToCluster method added to add individual buckets
-EntityCbDao
:convertToRawJsonDoc method added to skip extra step of converting JsonDoc
:updated crud methods that used JsonDoc to use RawJsonDocument instead

the disconnect on the single cluster was already there as closeClusterConnection()

thanks again!