java.lang.NoClassDefFoundError:无法初始化com.datastax.driver.core.Cluster类

Prasad Shinde

我有一个Maven项目A

项目A的pom.xml:

<dependencies>
       <dependency> 
            <groupId>com.app.cops</groupId>
            <artifactId>cassandra-logging</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
</dependencies>

cassandra-logging项目的pom.xml:

<dependencies>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty</artifactId>
            <version>3.9.0.Final</version>
        </dependency>
        <dependency>
            <groupId>com.codahale.metrics</groupId>
            <artifactId>metrics-core</artifactId>
            <version>3.0.2</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.5</version>
        </dependency>
        <dependency>
            <groupId>com.datastax.cassandra</groupId>
            <artifactId>cassandra-driver-core</artifactId>
            <version>3.0.0</version>
        </dependency>   
        <dependency>
            <groupId>com.datastax.cassandra</groupId>
            <artifactId>cassandra-driver-mapping</artifactId>
            <version>3.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>19.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.3.1</version>
        </dependency>
  </dependencies>

警察记录项目具有以下代码:

CassandraCopsComponentLogger.instance = new CassandraCopsComponentLogger();

                String hosts = CassandraClientUtil.getHost();
                String localDC = CassandraClientUtil.getLocalDC();
                Cluster cluster;
                if (StringUtils.isNotEmpty(localDC))
                {
                    cluster = Cluster.builder().addContactPoints(hosts.split(","))
                            .withCredentials(CassandraCopsComponentLogger.USER_NAME, CassandraCopsComponentLogger.AUTH_CODE)
                            .withQueryOptions(new QueryOptions().setConsistencyLevel(ConsistencyLevel.LOCAL_ONE))
                            .withLoadBalancingPolicy(new TokenAwarePolicy(DCAwareRoundRobinPolicy.builder().withLocalDc(localDC).build())).build();
                }
                else
                {
                    cluster = Cluster.builder().addContactPoints(hosts.split(","))
                            .withCredentials(CassandraCopsComponentLogger.USER_NAME, CassandraCopsComponentLogger.AUTH_CODE)
                            .withQueryOptions(new QueryOptions().setConsistencyLevel(ConsistencyLevel.LOCAL_ONE)).build();
                }

                Session session = cluster.connect();
                CassandraCopsComponentLogger.mappingManager = new MappingManager(session);

我继续在以下行获取异常:

cluster = Cluster.builder().addContactPoints(hosts.split(","))

我在cassandra-logging项目中有一个单元测试,可以在此代码下正常工作。但是当我从项目AI调用相同的代码时

java.lang.NoClassDefFoundError: Could not initialize class com.datastax.driver.core.Cluster
Prasad Shinde

我可以通过将cassandra依赖版本降级为来解决此问题<version>2.1.9</version>不确定如何提供帮助,但我能够继续前进。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

java.lang.NoClassDefFoundError:无法初始化类org.powermock.modules.junit4.rule.PowerMockRule

java.lang.NoClassDefFoundError:无法初始化类javax.media.jai.JAI

Java,Spark和Cassandra java.lang.ClassCastException:com.datastax.driver.core.DefaultResultSetFuture无法投射为阴影

java.lang.NoClassDefFoundError:无法初始化类org.bytedeco.javacpp.avutil

com.datastax.driver.core.exceptions.InvalidQueryException:未配置的表peers_v2

java.lang.NoClassDefFoundError:无法初始化类java.awt.Toolkit

java.lang.NoClassDefFoundError:无法初始化类XXX

原因:java.lang.NoClassDefFoundError:无法初始化类com.jayway.restassured.RestAssured

包括redshift jdbc驱动程序:无法实例化驱动程序类“ com.amazon.redshift.jdbc.Driver”:java.lang.NoClassDefFoundError

拒绝对先前失败的类java.lang.Class <nt>进行重新初始化:java.lang.NoClassDefFoundError

java.lang.NoClassDefFoundError:无法初始化类xxx.xxx.xxx.HibernateUtil

我们如何将com.datastax.driver.core.LocalDate转换为java.util.Date?

春季:java.lang.NoClassDefFoundError:无法初始化类

ARM64计算机上的Cassandra启动失败(java.lang.NoClassDefFoundError:无法初始化com.sun.jna.Native类)

Zeppelin java.lang.NoClassDefFoundError:无法初始化类org.apache.spark.rdd.RDDOperationScope $

关于java.lang.NoClassDefFoundError:无法初始化类org.xerial.snappy.Snappy

com.datastax.driver.core.exceptions.BusyPoolException

java.lang.NoClassDefFoundError:无法初始化com.googlecode.objectify.ObjectifyService类

带有Java 9 java.lang.NoClassDefFoundError的Oracle JDBC驱动程序:无法初始化类oracle.jdbc.OracleDriver

Corda-无法初始化主类胶囊(引起原因:java.lang.NoClassDefFoundError:java / lang / instrument / Instrumentation)

获取java.lang.NoClassDefFoundError:升级到POI 4.0.0后无法初始化类org.apache.poi.ooxml.util.DocumentHelper

原因:java.lang.NoClassDefFoundError:无法初始化类javassist.util.proxy.DefineClassHelper

com.datastax.driver.core.utils.UUIDs.startOf如何工作?

java.lang.NoClassDefFoundError:无法初始化类org.springframework.mail.javamail.SmartMimeMessage

com.datastax.oss-> java-driver-core和com.datastax.cassandra-> cassandra-driver-core之间的Cassandra区别

java.lang.NoClassDefFoundError:无法初始化类sun.nio.ch.FileChannelImpl

Grails域类单元测试,约束设置问题-java.lang.NoClassDefFoundError:无法初始化

java.lang.NoClassDefFoundError:无法初始化类org.apache.commons.logging.LogFactory

线程“主”中的异常java.lang.NoClassDefFoundError无法初始化类org.bytedeco.javacpp.avutil