Exception when trying to instantiate Reflections
Under JDK8:
Code:
Reflections reflections = new Reflections("my.package");
Exception
java.lang.NoSuchMethodError: com.google.common.collect.Sets$SetView.iterator()Lcom/google/common/collect/UnmodifiableIterator;
at org.reflections.Reflections.expandSuperTypes(Reflections.java:380) ~[reflections-0.9.11.jar:na]
at org.reflections.Reflections.<init>(Reflections.java:126) ~[reflections-0.9.11.jar:na]
at org.reflections.Reflections.<init>(Reflections.java:168) ~[reflections-0.9.11.jar:na]
at org.reflections.Reflections.<init>(Reflections.java:141) ~[reflections-0.9.11.jar:na]
That means you have an old version of Guava in your class path. Check your Guava version.
I see the project have 2 guava libraries version 18.0 and 20.0 respectively.
20.0 is pulled in by Reflections most likely, but 18.0 is probably winning. You could try setting up managed dependencies to force only 20. I currently force 24.1-jre and it works well.
@Rafaelsk I have also encountered this problem, how do you solve it?
@haixuan8192 I didn't. I couldn't use the library so I used Java's plain Reflection code form the JDK library.