JAVA - ClassNotFoundExceptin-com.couchbase.client.core.env.CoreEnviromnet

java

#1

Using the java couchbase gradle api ‘com.couchbase.client:java-client:2.7.0’

- unable to get any data or error from query if i run through the gradle build command 'gradle run’

code is :
bucket.async()
.query(select("*").from(i(“sample-bucket”)).limit(10))
.flatMap(result ->
result.errors()
.flatMap(e -> Observable.<AsyncN1qlQueryRow>error(new Exception("N1QL Error/Warning: " + e)))
.switchIfEmpty(result.rows())
)
.map(AsyncN1qlQueryRow::value)
.subscribe(
rowContent -> System.out.println(rowContent),
runtimeError -> runtimeError.printStackTrace()
);

Getting output, only bucket opened not getting any data.

Nov 19, 2018 3:56:02 PM com.couchbase.client.core.CouchbaseCore
INFO: CouchbaseEnvironment: {sslEnabled=false, sslKeystoreFile=‘null’, sslTruststoreFile=‘null’, sslKeystorePassword=false, sslTruststorePassword=false, sslKeystore=null, sslTruststore=null, bootstrapHttpEnabled=true, bootstrapCarrierEnabled=true, bootstrapHttpDirectPort=8091, bootstrapHttpSslPort=18091, bootstrapCarrierDirectPort=11210, bootstrapCarrierSslPort=11207, ioPoolSize=8, computationPoolSize=8, responseBufferSize=16384, requestBufferSize=16384, kvServiceEndpoints=1, viewServiceEndpoints=12, queryServiceEndpoints=12, searchServiceEndpoints=12, configPollInterval=2500, configPollFloorInterval=50, networkResolution=NetworkResolution{name=‘auto’}, ioPool=NioEventLoopGroup, kvIoPool=null, viewIoPool=null, searchIoPool=null, queryIoPool=null, analyticsIoPool=null, coreScheduler=CoreScheduler, memcachedHashingStrategy=DefaultMemcachedHashingStrategy, eventBus=DefaultEventBus, packageNameAndVersion=couchbase-java-client/2.7.0 (git: 2.7.0, core: 1.7.0), retryStrategy=BestEffort, maxRequestLifetime=75000, retryDelay=ExponentialDelay{growBy 1.0 MICROSECONDS, powers of 2; lower=100, upper=100000}, reconnectDelay=ExponentialDelay{growBy 1.0 MILLISECONDS, powers of 2; lower=32, upper=4096}, observeIntervalDelay=ExponentialDelay{growBy 1.0 MICROSECONDS, powers of 2; lower=10, upper=100000}, keepAliveInterval=30000, continuousKeepAliveEnabled=true, keepAliveErrorThreshold=4, keepAliveTimeout=2500, autoreleaseAfter=2000, bufferPoolingEnabled=true, tcpNodelayEnabled=true, mutationTokensEnabled=false, socketConnectTimeout=1000, callbacksOnIoPool=false, disconnectTimeout=25000, requestBufferWaitStrategy=com.couchbase.client.core.env.DefaultCoreEnvironment$4@7f560810, certAuthEnabled=false, coreSendHook=null, forceSaslPlain=false, compressionMinRatio=0.83, compressionMinSize=32, compressionEnabled=true, operationTracingEnabled=true, operationTracingServerDurationEnabled=true, tracer=ThresholdLogTracer, orphanResponseReportingEnabled=true, orphanResponseReporter=DefaultOrphanResponseReporter, keyValueServiceConfig=KeyValueServiceConfig{minEndpoints=1, maxEndpoints=1, pipelined=true, idleTime=0}, queryServiceConfig=QueryServiceConfig{minEndpoints=0, maxEndpoints=12, pipelined=false, idleTime=300}, searchServiceConfig=SearchServiceConfig{minEndpoints=0, maxEndpoints=12, pipelined=false, idleTime=300}, viewServiceConfig=ViewServiceConfig{minEndpoints=0, maxEndpoints=12, pipelined=false, idleTime=300}, analyticsServiceConfig=AnalyticsServiceConfig{minEndpoints=0, maxEndpoints=12, pipelined=false, idleTime=300}, queryTimeout=75000, viewTimeout=75000, searchTimeout=75000, analyticsTimeout=75000, kvTimeout=2500, connectTimeout=5000, dnsSrvEnabled=false, propagateParentSpan=true}
Nov 19, 2018 3:56:03 PM com.couchbase.client.core.node.CouchbaseNode signalConnected
INFO: Connected to Node 10.9.123.84/10.9.123.84
Nov 19, 2018 3:56:03 PM com.couchbase.client.core.config.DefaultConfigurationProvider upsertBucketConfig
INFO: Selected network configuration: default
Nov 19, 2018 3:56:03 PM com.couchbase.client.core.config.DefaultConfigurationProvider$8 call
INFO: Opened bucket sample-bucket

  • To debug the issue, if i want to run java file in debug mode getting error as
    xception in thread “main” java.lang.NoClassDefFoundError: com/couchbase/client/core/env/CoreEnvironment
    at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
    at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:802)
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:700)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    at com.example.couchbase.CouchbaseProject.main(CouchbaseProject.java:25)
    Caused by: java.lang.ClassNotFoundException: com.couchbase.client.core.env.CoreEnvironment
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    … 10 more

Can anybody help out to fix the issue?

Thanks


#2

It looks like you’re missing the transitive dependencies. Does your gradle setup pull those in as well? You’ll need the core-io package among others, all described in the docs and on maven central.


#3

Hey @ingenthr

yes, the above mentioned gradle setup pull all those required transitive dependcies.


#4

Then something about running is not putting it in the classpath. As you can see from the ClassNotFoundException, it’s not finding the core-io for some reason.