-2

I'm using the Bloom filter and Funnel classes in Guava. Rather than adding the JARs individually, I added a dependency on Guava using Maven.

When I used the Bloom filter class originally, it had no issues. But when I started using the Funnel class (in the same file with the same dependency section, classpath, etc.) I get the errors

java.lang.NoClassDefFoundError: com/google/common/hash/Funnels

and

java.lang.ClassNotFoundException.

zx485
  • 28,498
  • 28
  • 50
  • 59
Chris H.
  • 1
  • 2
  • 3
    Which version are you depending on using Maven? Where are you observing the error? You need to show the actual error message and the relevant parts of your `pom.xml` at a minimum. Ideally you should provide a [mcve]. – Daniel Pryden Jan 10 '18 at 20:50

1 Answers1

-1

Guava is a library people typically have problems with because it frequently breaks backward compatibility. Also many projects include it as a transitive dependency, so you can be stuck in a situation with multiple versions of guava on your class path. Try the following:

  • Make sure the version of guava you've added as a dependency is the same version of guava that you read the docs for. The Funnels class was added in version 11.0 (see the Since section in the javadoc), so if you are depending on a version older than that the Funnels class won't exist.
  • Run the mvn dependency:tree command to see all the versions of guava that are being sucked into your classpath. If you see more than one version of guava, exclude guava from the dependencies that rely on it in your pom.
ilooner
  • 2,480
  • 15
  • 32