Astyanax cassandra: Type org.apache.cassandra.thrift.Cassandra $ Client cannot be resolved. This indirectly refers to the required .class files

My internship requires me to get acquainted with cassandra. I downloaded astyanax cassandra from: https://github.com/Netflix/astyanax

After building astyanax from source using the commands: git clone git @ github.com: Netflix / astyanax.git cd astyanax. / gradlew build

I created a new java project and copy + paste the sample code: https://github.com/Netflix/astyanax/blob/master/astyanax-examples/src/main/java/com/netflix/astyanax/examples/AstCQLClient.java

Now having problems. I fixed the path configuration that imports all .jar files created from the gradlew assembly. But one (long) line of code is highlighted in red:

context = new AstyanaxContext.Builder() .forCluster("Test Cluster") .forKeyspace("test1") .withAstyanaxConfiguration(new AstyanaxConfigurationImpl() .setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE) ) .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool") .setPort(9160) .setMaxConnsPerHost(1) .setSeeds("127.0.0.1:9160") ) .withAstyanaxConfiguration(new AstyanaxConfigurationImpl() .setCqlVersion("3.0.0") .setTargetCassandraVersion("1.2")) .withConnectionPoolMonitor(new CountingConnectionPoolMonitor()) .buildKeyspace(ThriftFamilyFactory.getInstance()); 

Warning message: Type org.apache.cassandra.thrift.Cassandra $ Client cannot be resolved. This indirectly refers to the required .class files

I need expert help. Thanks a lot!

+4
source share
2 answers

It looks like you are missing the thrift binding (thrifty jar file). Either this, or you are using an incompatible version of frugality. A simple solution is to use Maven and add an Astyanax dependency to your project. A more sophisticated solution is to verify that your version of lean is compatible with your version of Astyanax.

Maven dependency (add this to your pom file):

 <dependency> <groupId>com.netflix.astyanax</groupId> <artifactId>astyanax</artifactId> <version>1.56.42</version> </dependency> 

You can develop a compatible version of Thrift for your Astyanax client using the Astyanax wiki . But, knowing that you built the project from Github, you want the latest savings to be compatible with Cassandra, so you are behind Thrift 9.0+ (e.g. libthrift-0.9.0.jar ).

+3
source

I think, first of all, you should correctly install Cassandra Server on your local one. You can find the latest source from Cassandra Repo .

Then you can follow this link to configure the Cassandra server. Although I do not think that you need to change anything in the configuration files, since the cassandra source is correctly configured to work in local mode.

Then create a Maven project from the IDE, add the dependency shown by @Lyuben Todorov ie

 <dependency> <groupId>com.netflix.astyanax</groupId> <artifactId>astyanax</artifactId> <version>1.56.42</version> </dependency> 

Then try a sample example from the Astyanax wiki

0
source

Source: https://habr.com/ru/post/1493084/


All Articles