Working with Maven and RequestFactory in GWT 2.4

Posted by David Chandler - Friday, September 16, 2011 at 4:28:00 PM

GWT 2.4 introduced changes to both Maven and RequestFactory, and we've recently updated the GWT wiki and sample apps with the latest and greatest:

RequestFactory now does compile-time validation to ensure that your service implementations match your client-side interfaces. This feature is implemented using an annotation processor which must be configured in Eclipse or in your Maven POM. When configured in Eclipse, you will now see warnings and errors in the IDE anywhere your client- and server-side RF code don't match.

In addition, the RequestFactory jars are now in Maven Central. Note that the Maven groupId for RF artifacts differs from the rest of the GWT artifacts since RF can be used in Android clients as well as GWT. If you're using RequestFactory instead of GWT-RPC, you no longer need gwt-servlet. Instead, you can use the much smaller requestfactory-server jar and requestfactory-apt (which contains the RF interface validation tool). You do not need requestfactory-client for GWT projects as the required classes are already included in gwt-user. The requestfactory-client jar is intended for non-GWT (Android) clients using RequestFactory.

  <!-- see sample projects for correct placement -->

The mobilewebapp and dynatablerf samples show everything working together and have been tested in Eclipse 3.6 and 3.7.

If you also have the Eclipse Subversive plugin installed (see, you should be able to try the mobilewebapp sample as easily as

  1. File > Import > Checkout Maven projects from SCM, point to
  3. Run as > Web application

Special thanks to Jeff Larsen for the RequestFactory POM sauce that works in Eclipse Indigo!


Asaf said...

Very cool,
Thanks guys for the hard work and the latest improvements of RF.

Boris_siroB said...

The `File > Import > Checkout Maven projects from SCM` technique also works with Subclipse. All that's needed is to install the m2e-subclipse SCM connector (look for "Find more SCM connectors in the m2e Marketplace" line in the wizard dialog.

savilak said...

Hi guys,

I did what you say and I get two errors:


Description Resource Path Location Type
The type javax.validation.ConstraintViolation cannot be resolved.
It is indirectly referenced from required .class files /MobileWebApp/src/main/java/com/google/gwt/sample/mobilewebapp/presenter/tasklist line 1 Java Problem


Description Resource Path Location Type
Error executing (org.bsc.maven:maven-processor-plugin:2.0.5:process:process:generate-sources) pom.xml /MobileWebApp line 189 Maven Build Problem

What might be the solution to this?

KOMA said...

IMO, it is masochism to use maven in combination with GWT.

Brandon said...

I'm digging the RequestFactory wiring! I've built one demo and working on another to get the feel.

May I suggest more info for RequestFactory doc :) I think these few things could add some clarification to the docs.
1. the annotation processer setup and libraries needed to do this. (more than one way) I've read 1.6 should detect and do this automatically but I haven't been able to reproduce the errors and diagnose this yet.
2. Could you add a FAQ, and reference the errors that could exist when a person forgets the dependencies, like gwt-dep-libs.jar. Also, all the dependencies needed are not listed
3. Could you create a section of reference to the JPA persistence reference, in reference to the annotations that could be used on persistence vars. ObjectDB has a really nice documentation on JPA/JDO.
4. JPA owned Entities documentation is small, and would suggest more info on this. Owned Collection of another entity docs would be nice.
5. A wiring diagram or piping diagram might be a nice wish
6. Future idea, might be add sample contents project creation based on RequestFactory.

Thanks for creating RequestFactory!
Brandon Donnelson

David Chandler said...

Thanks, Brandon, good ideas. I'll add these when I get a chance.

Viacheslav Dobromyslov said...

Also have the problem mentioned previously with javax.validation. Steps to fix it:
1. Add external jar 'validation-api-1.0.0.GA.jar'
2. mvn package and then mvn gwt:run

But the problem stayed when run from eclipse.

Mark Lesk said...

Also encountered the problem mentioned previously with javax.validation. Steps to fix it so that it works when run from within eclipse:

1. Move the dependency in the pom.xml for javax.validation to be the first dependency.

2. From project popup menu Maven-> Update Project Configuration

Root problem is that another dependency defined in the project includes an older version of javax.validation that does not contain the ConstraintViolation class.