On upgrading Guava to the latest 23.5 getting NoSuchMethodError for Preconditions.checkArgument

2,259 views
Skip to first unread message

subhara...@gmail.com

unread,
Dec 21, 2017, 8:40:25 AM12/21/17
to guava-discuss
On upgrading Guava to the latest 23.5-jre from 18.0 I am getting an exception like below

Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V
    at com
.van.common.VanExecutors.getSpec(VanExecutors.java:91)
    at com
.van.common.VanExecutors.newFixedSizeExecutor(VanExecutors.java:114)
    at com
.van.storage.config.ConfigStoreFactory.getOrCreateUncachedStore(ConfigStoreFactory.java:56)
    at com
.van.storage.config.ConfigStoreFactory.getOrCreateStore(ConfigStoreFactory.java:74)
    at com
.van.storage.config.PolicyManager.loadFromSystemProperties(PolicyManager.java:79)
    at com
.van.tools.metric.HbaseMetricStoreSetup.main(HbaseMetricStoreSetup.java:25)

The relevant code

private ExecutorSpec getSpec(String executorName) {
       
Preconditions.checkArgument(isValid(), "Not initialized");
       
Preconditions.checkArgument(NullOrEmpty.isFalse(executorName), "No executor name given");
       
Preconditions.checkArgument(POOL_NAME_PATTERN.matcher(executorName).matches(), "Executor name %s must end with -exec", executorName);
       
for (ExecutorSpec spec : executorsSpec.getExecutorSpecList()) {
           
if (spec.getName().equalsIgnoreCase(executorName)) return spec;
       
}
       
return null;
   
}

As per the stacktrace line 91 is the last Preconditions check.

As per the discussion in stackoverflow it seems during compilation it is using the latest version but while running it is picking the old version from classpath. 

I have verified in mvn dependency:tree that there is no reference to the older version. I have also deleted by .m2 directory but while compiling I am seeing it is still downloading the older versions of guava. 

Can someone let me know how can I get around this ?


subhara...@gmail.com

unread,
Dec 21, 2017, 8:42:35 AM12/21/17
to guava-discuss

Ron Shapiro

unread,
Dec 21, 2017, 8:55:14 AM12/21/17
to subhara...@gmail.com, guava-discuss

From the looks of it, VanExecutors was compiled against the old version of Guava and it too must be updated. Let's continue on the StackOverflow thread and not in email for everyone's benefit.


--
guava-...@googlegroups.com
Project site: https://github.com/google/guava
This group: http://groups.google.com/group/guava-discuss
 
This list is for general discussion.
To report an issue: https://github.com/google/guava/issues/new
To get help: http://stackoverflow.com/questions/ask?tags=guava
---
You received this message because you are subscribed to the Google Groups "guava-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to guava-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/guava-discuss/2336864f-c9eb-4a1c-a0e6-1474e0277e3b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages