I can't get Guava to work with GWT. I'm using Eclipse, I've added both guava-11.0.2.jar
and guava-gwt-11.0.2.jar
to my class path, inherited the module com.google.common.collect.Collect
in my gwt.xml
file but still can't get it working.
It compiles but when I run it a lot of error appear. Many of them refering to unresolvable annotation javax.annotation.Nullable
I tried adding jsr305.jar
to my class path but nothing chanded.
Also some errors appear depending on which version of Guava I include (tried with 11.0.2, 11.0.1, 10.0.1) and if I include or not the jsr305.jar
Some examples of these error are:
PersonActivity.PersonFilterPredicate
must implement the inherited abstract method Predicate<PersonRoleProxy>.apply(Object)
compare(T, T)
in the type Ordering<T>
is not applicable for the arguments (Object, Object)
Which is quite strange because the code compiles and these kind of error should appear at compile time.
We have been embarrassingly unable to figure out the solution to the @Nullable
problem, which we believe to be a GWT problem. You can follow along at http://code.google.com/p/guava-libraries/issues/detail?id=776 We're trying to get help from the GWT team, but things have been kind of crazy lately for the people who work on the part of the compiler we're interested in. It does look like you can work around the problem by removing -strict
from your GWT compilation arguments, but of course that's a terrible workaround.
Other users' experiences suggest that the weird other errors you're seeing are related to the @Nullable
problem, though I haven't seen definitive confirmation. You might also confirm that all your imports are com.google.common.*
and not com.google.gwt.thirdparty.guava.common.*
Sorry for all the trouble. This is one of a few major thorns in our side at the moment.
The following workaround works for GWT 2.4.0 with
Create a file named Annotation.gwt.xml with the following content:
<module>
<source path=""/>
</module>
Within the archive jsr305-1.3.9.jar copy this file into sub-directory javax/annotation.
Add the following line to your applications .gwt.xml file:
<inherits name='javax.annotation.Annotation'/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.