3

I am trying to use the sstableloader for bulk loading to Cassandra. I am trying to use code from here : https://github.com/yukim/cassandra-bulkload-example

I run into java.lang.NoSuchMethodError: com.google.common.collect.Sets.newConcurrentHashSet exception during running of application. The application imports the following libraries :

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.List;

import org.supercsv.io.CsvListReader;
import org.supercsv.prefs.CsvPreference;

import org.apache.cassandra.config.Config;
import org.apache.cassandra.dht.Murmur3Partitioner;
import org.apache.cassandra.exceptions.InvalidRequestException;
import org.apache.cassandra.io.sstable.CQLSSTableWriter;

The exception is coming from the following line of code :

    // Prepare SSTable writer
CQLSSTableWriter.Builder builder = CQLSSTableWriter.builder();

I am using the following external jars for my application :

super-csv-2.0.0.jar
cassandra-all-3.4.jar
gradle-wrapper.jar
slf4j-api-1.7.19.jar
concurrentlinkedhashmap-lru-1.3.jar
slf4j-simple-1.7.19.jar
guava.jar
google-collections-1.0.jar

I am unable to figure which libraries i am missing.

enter image description here

Digging into com.google.comman.collect.Sets i cannot find the newConcurrentHashSet method. However the code seems to be calling it

enter image description here

srai
  • 1,023
  • 2
  • 14
  • 27
  • Guava supplants the google-collections jar. What happens if you get rid of it? – Robert Moskal Mar 27 '16 at 15:24
  • @Robert Moskal : If i remove the guava.jar and just have the google-collections-1.0.jar i still get the NoSuchMethodError: com.google.common.collect.Sets.newConcurrentHashSet – srai Mar 27 '16 at 15:26
  • The path to the method is `com.google.common.collect.Sets` , so the method has to be in google-collections – ralf htp Mar 27 '16 at 15:27
  • @ralf htp : the method doesn't seem to be present. – srai Mar 27 '16 at 15:38
  • In this thread is a related error http://stackoverflow.com/questions/27089126/nosuchmethoderror-sets-newconcurrenthashset-while-running-jar-using-hadoop. Check your classpath (to the jars) and see which libraries are in (http://docs.oracle.com/javase/7/docs/technotes/tools/solaris/classpath.html) (http://stackoverflow.com/questions/2096283/including-jars-in-classpath-on-commandline-javac-or-apt) – ralf htp Mar 27 '16 at 15:52
  • Other way. As in the answer. You keep guava and get rid of collections. – Robert Moskal Mar 27 '16 at 15:55
  • See this http://ben-tech.blogspot.de/2014/11/nosuchmethoderror-comgooglecommoncollec.html is really interesting... – ralf htp Mar 27 '16 at 16:09

1 Answers1

11

You should remove google-collections-1.0.jar.

Google Collection is renamed to Guava so you have multiple implementation of the same classes. And the "old" implementation of com.google.common.collect.Sets does not have this method and thats why you get the NoSuchMethodError.

https://code.google.com/archive/p/google-collections/

gustf
  • 1,959
  • 13
  • 20
  • now getting "java.lang.NoSuchMethodError: com.google.common.collect.ImmutableSet.builder()Lcom/google/common/collect/ImmutableSet$Builder;" f – srai Mar 27 '16 at 16:08
  • Ok, but good that you now passed the first issue. If you update the post with the full classpath you are using and the stacktrace for the new error me and others might be able to help you with this also. Btw, did you do a clean build after you removed google-collections-1.0.jar? – gustf Mar 27 '16 at 16:57
  • @skrai This answer has gotten you past the issue specified in your question. If you have a new issue (new error message), then please upvote/accept this answer and ask new question. – Aaron Mar 27 '16 at 17:23
  • @srai did you fixed the issue "java.lang.NoSuchMethodError: com.google.common.collect.ImmutableSet.builder()Lcom/google/common/collect/ImmutableSet$Builder; ????? – Umesh Chakradhar Jan 21 '21 at 09:47