Guava Java eventbus instantiation error

I'm trying to use Google's guava Library's eventbus

Starting with guava's documentation, it should be easy to instantiate the eventbus object

My code:

package test;

import com.google.common.eventbus.EventBus;

public class Test {
    public static void main(String[] args) {
        EventBus bus = new EventBus("Sample");
    }
}

I received this error:

Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Objects.firstNonNull(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
at com.google.common.cache.CacheBuilder.getKeyStrength(CacheBuilder.java:355)
at com.google.common.cache.CustomConcurrentHashMap.<init>(CustomConcurrentHashMap.java:206)
at com.google.common.cache.ComputingCache.<init>(ComputingCache.java:39)
at com.google.common.cache.CacheBuilder.build(CacheBuilder.java:569)
at com.google.common.eventbus.EventBus.<init>(EventBus.java:156)
at test.Test.main(Test.java:7)
Java Result: 1

I tried to use guava 10.0, 11.0 and 12.0 and always made the same mistakes I'm on OSX lion and I'm using NetBeans 7.1: I've tried Java 6 (32 and 64 bit) and Java 7: there's no improvement I can't find anything at Google Is this a guava problem? Or, usually, what do I miss?

Best wishes,

Alexandro

Solution

In order to extend what @ biziclop said, you are most likely to have both the latest version of guava and the version of guava before 3.0 on Google collect or similar path Objects. Firstnonnull was added in 3.0 to indicate that an older version of the class is being loaded

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>