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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Debraj Manna
HI

Cross-posting from stackoverflow
<https://stackoverflow.com/questions/47900817/on-upgrading-guava-to-the-latest-23-5-getting-nosuchmethoderror-for-precondition>
if
anyone can help me here

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.

Can someone let me know what is going wrong?

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 ?

Thanks,
Reply | Threaded
Open this post in threaded view
|

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

Paul Hammant
What did "mvn dependency:tree" report before and after the change?