Why am I getting this error when the dependency is being included?
Could not find implementation class: org.janusgraph.diskstorage.cql.CQLStoreManager
<dependency>
<groupId>org.janusgraph</groupId>
<artifactId>janusgraph-cql</artifactId>
Please know that I am new to JanusGraph and GraphDBs in-general, as well as Cassandra.
docker run --name jg-cassandra -d -e CASSANDRA_START_RPC=true -p 9160:9160 -p 9042:9042 -p 7199:7199 -p 7001:7001 -p 7000:7000 cassandra:3.11
janusgraph.cql.properties
into Cassandra [Docker container]
docker exec -i jg-cassandra mkdir -p /opt/janusgraph/conf
docker cp janusgraph-cql.properties jq-cassandra:/opt/janusgraph/conf
JanusGraph janusGraph = JanusGraphFactory.build().set("storage.backend", "cql").set("storage.hostname", "localhost:9042").open();
Could not instantiate implementation: org.janusgraph.diskstorage.cql.CQLStoreManager
2023-05-08 10:52:10,722 [INFO] [c.d.o.d.i.c.ContactPoints.main] :: Contact point localhost:9042 resolves to multiple addresses, will use them all ([localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1])
Exception in thread "main" java.lang.IllegalArgumentException: Could not instantiate implementation: org.janusgraph.diskstorage.cql.CQLStoreManager
at org.janusgraph.util.system.ConfigurationUtil.instantiate(ConfigurationUtil.java:79)
at org.janusgraph.diskstorage.Backend.getImplementationClass(Backend.java:537)
at org.janusgraph.diskstorage.Backend.getStorageManager(Backend.java:498)
at org.janusgraph.graphdb.configuration.builder.GraphDatabaseConfigurationBuilder.build(GraphDatabaseConfigurationBuilder.java:64)
at org.janusgraph.core.JanusGraphFactory.open(JanusGraphFactory.java:176)
at org.janusgraph.core.JanusGraphFactory.open(JanusGraphFactory.java:147)
at org.janusgraph.core.JanusGraphFactory.open(JanusGraphFactory.java:137)
at org.janusgraph.core.JanusGraphFactory$Builder.open(JanusGraphFactory.java:277)
at Main.main(Main.java:6)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at org.janusgraph.util.system.ConfigurationUtil.instantiate(ConfigurationUtil.java:73)
... 8 more
Caused by: java.lang.NoClassDefFoundError: com/datastax/oss/protocol/internal/SegmentCodec
at com.datastax.oss.driver.internal.core.context.DefaultDriverContext.<init>(DefaultDriverContext.java:170)
at com.datastax.oss.driver.api.core.session.SessionBuilder.buildContext(SessionBuilder.java:968)
at com.datastax.oss.driver.api.core.session.SessionBuilder.buildDefaultSessionAsync(SessionBuilder.java:904)
at com.datastax.oss.driver.api.core.session.SessionBuilder.buildAsync(SessionBuilder.java:817)
at com.datastax.oss.driver.api.core.session.SessionBuilder.build(SessionBuilder.java:835)
at org.janusgraph.diskstorage.cql.builder.CQLSessionBuilder.build(CQLSessionBuilder.java:81)
at org.janusgraph.diskstorage.cql.CQLStoreManager.<init>(CQLStoreManager.java:137)
at org.janusgraph.diskstorage.cql.CQLStoreManager.<init>(CQLStoreManager.java:118)
... 14 more
Caused by: java.lang.ClassNotFoundException: com.datastax.oss.protocol.internal.SegmentCodec
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
... 22 more
Process finished with exit code 1
│ pom.xml
│
├───src
│ ├───main
│ │ ├───java
│ │ │ Main.java
│ │ │
│ │ └───resources
│ │ │ log4j2.xml
│ │ │
│ │ ├───conf
│ │ │ remote-graph.properties
│ │ │ remote-objects.yaml
Main.java
import org.janusgraph.core.JanusGraph;
import org.janusgraph.core.JanusGraphFactory;
public class Main {
public static void main(String[] args) {
JanusGraph janusGraph = JanusGraphFactory.build().set("storage.backend", "cql").set("storage.hostname", "localhost:9042").open();
janusGraph.close();
}
}
remote-graph.properties
gremlin.remote.remoteConnectionClass=org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection
gremlin.remote.driver.clusterFile=src/main/resources/conf/remote-objects.yaml
gremlin.remote.driver.sourceName=g
hosts: [localhost]
port: 18182
serializer: {
className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0,
config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }}
pom.xml
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j2-impl</artifactId>
<version>2.20.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.janusgraph/janusgraph-core -->
<dependency>
<groupId>org.janusgraph</groupId>
<artifactId>janusgraph-core</artifactId>
<version>1.0.0-20230504-014643.988c094</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.janusgraph/janusgraph-cql -->
<dependency>
<groupId>org.janusgraph</groupId>
<artifactId>janusgraph-cql</artifactId>
<version>1.0.0-20230504-014643.988c094</version>
</dependency>
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>gremlin-core</artifactId>
<version>3.6.2</version>
</dependency>
<dependency>
<groupId>com.esri.geometry</groupId>
<artifactId>esri-geometry-api</artifactId>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>com.datastax.dse</groupId>
<artifactId>dse-java-driver-core</artifactId>
<version>2.4.0</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.15.0</version>
</dependency>
</dependencies>
janusgraph-cql.properties
# Copyright 2019 JanusGraph Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# JanusGraph configuration sample: Cassandra over a socket
#
# This file connects to a Cassandra daemon running on localhost via
# CQL. Cassandra must already be started before starting JanusGraph
# with this file.
# The implementation of graph factory that will be used by gremlin server
#
# Default: org.janusgraph.core.JanusGraphFactory
# Data Type: String
# Mutability: LOCAL
gremlin.graph=org.janusgraph.core.JanusGraphFactory
# The primary persistence provider used by JanusGraph. This is required.
# It should be set one of JanusGraph's built-in shorthand names for its
# standard storage backends (shorthands: berkeleyje, cql, hbase, inmemory)
# or to the full package and classname of a custom/third-party
# StoreManager implementation.
#
# Default: (no default value)
# Data Type: String
# Mutability: LOCAL
storage.backend=cql
# The hostname or comma-separated list of hostnames of storage backend
# servers. This is only applicable to some storage backends, such as
# cassandra and hbase.
#
# Default: 127.0.0.1
# Data Type: class java.lang.String[]
# Mutability: LOCAL
storage.hostname=127.0.0.1
# The name of JanusGraph's keyspace. It will be created if it does not
# exist.
#
# Default: janusgraph
# Data Type: String
# Mutability: LOCAL
storage.cql.keyspace=janusgraph
# The name of the local or closest Cassandra datacenter. This value will
# be passed into CqlSessionBuilder.withLocalDatacenter.
#
# Default: datacenter1
# Data Type: String
# Mutability: MASKABLE
storage.cql.local-datacenter=datacenter1
# Whether to enable JanusGraph's database-level cache, which is shared
# across all transactions. Enabling this option speeds up traversals by
# holding hot graph elements in memory, but also increases the likelihood
# of reading stale data. Disabling it forces each transaction to
# independently fetch graph elements from storage before reading/writing
# them.
#
# Default: false
# Data Type: Boolean
# Mutability: MASKABLE
cache.db-cache = true
# How long, in milliseconds, database-level cache will keep entries after
# flushing them. This option is only useful on distributed storage
# backends that are capable of acknowledging writes without necessarily
# making them immediately visible.
#
# Default: 50
# Data Type: Integer
# Mutability: GLOBAL_OFFLINE
#
# Settings with mutability GLOBAL_OFFLINE are centrally managed in
# JanusGraph's storage backend. After starting the database for the first
# time, this file's copy of this setting is ignored. Use JanusGraph's
# Management System to read or modify this value after bootstrapping.
cache.db-cache-clean-wait = 20
# Default expiration time, in milliseconds, for entries in the
# database-level cache. Entries are evicted when they reach this age even
# if the cache has room to spare. Set to 0 to disable expiration (cache
# entries live forever or until memory pressure triggers eviction when set
# to 0).
#
# Default: 10000
# Data Type: Long
# Mutability: GLOBAL_OFFLINE
#
# Settings with mutability GLOBAL_OFFLINE are centrally managed in
# JanusGraph's storage backend. After starting the database for the first
# time, this file's copy of this setting is ignored. Use JanusGraph's
# Management System to read or modify this value after bootstrapping.
cache.db-cache-time = 180000
# Size of JanusGraph's database level cache. Values between 0 and 1 are
# interpreted as a percentage of VM heap, while larger values are
# interpreted as an absolute size in bytes.
#
# Default: 0.3
# Data Type: Double
# Mutability: MASKABLE
cache.db-cache-size = 0.5
Updated janusgraph-core
and janusgraph-cql
to be the same version: 1.0.0-20230504-014643.988c094
.
This still produces the same error.
@Boxuan Li Thanks! This did fix my issue!
Datastax.dse seems to fix on its own after adding in JanusGraph-CQL
.
I had been trying to address errors as they were logged out. And, I hadn't thought to remove them now as a different error log came up.
Looks like a library conflict problem. Not sure if this will fix the problem, but my suggestions are:
janusgraph-core
and janusgraph-cql
. Currently you are using different (could be conflicting) versions.dse-java-driver-core
dependency. The driver you need is included as a dependency of janusgraph-cql
.pom.xml
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j2-impl</artifactId>
<version>2.20.0</version>
</dependency>
<dependency>
<groupId>org.janusgraph</groupId>
<artifactId>janusgraph-core</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.janusgraph</groupId>
<artifactId>janusgraph-cql</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>