Getting Guava to work in GWT

I cannot get Guava to work with GWT. I am using Eclipse, I added both paths guava-11.0.2.jar

and guava-gwt-11.0.2.jar

in my classpath, inherited the module

in my file gwt.xml

, but still can't get it to work.

It compiles, but when I run it many errors appear. Many of them refer to the undecidable annotationjavax.annotation.Nullable

I tried adding jsr305.jar

to my classpath but nothing got in the way.

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 jsr305.jar

Some examples of these errors:

  • The type PersonActivity.PersonFilterPredicate

    must implement an inherited abstract methodPredicate<PersonRoleProxy>.apply(Object)

  • Method compare(T, T)

    in type is Ordering<T>

    not valid for arguments(Object, Object)

This is rather strange because the compilation of the code and such an error appear at compile time.


source to share

2 answers

We are confused by the inability to figure out a solution to the problem @Nullable

, which we consider to be a GWT problem. You can follow We are trying to get help from the GWT team but things have been a little crazy lately for people who are working from the side of interest us a compiler. It looks like you can fix the problem by removing -strict

GWT compilation from your arguments, but of course this is a terrible workaround.

Experience from other users suggests that the strange other errors you see are related to the problem @Nullable

, although I haven't seen definitive confirmation. You can also confirm that all of your imports*


Sorry for all the problems. It is currently one of the few large thorns on our side.



The following workaround works for GWT 2.4.0 with

  • Guava 14.0 RC1 and
  • jsr305-1.3.9.jar

Create a file named Annotation.gwt.xml with the following content:

  <source path=""/>


In the jsr305-1.3.9.jar archive, copy this file to the javax / annotation subdirectory.

Add the following line to your applications: .gwt.xml:

  <inherits name='javax.annotation.Annotation'/>




All Articles