GWT + Maven + GAE gotcha
Posted by David Chandler on March 8, 2011
It turns out that gwt-user-2.2.0, weighing in at 10.6 MB, is just over the App Engine size limit for a single file (10 MB) so you must enable jar splitting to deploy a GWT + Maven project to GAE. Actually, though, there is no need to deploy gwt-user because it’s only used for GWT compilation and GWT dev mode. The GWT Expenses sample POM correctly scopes the gwt-user dependency as “provided” in order to prevent this. However, the sample POM also says in the gwt-maven-plugin config:
<copyWebapp>true</copyWebapp>
This feature of gwt-maven-plugin copies src/main/webapp to the target folder in order for GWT dev mode (gwt:run) to work and inadvertently copies the gwt-user jar, too. Fortunately, if you’re using a POM with copyWebapp=true, you can configure the clean plugin to remove the gwt-user jar from the target folder before GAE deployment:
<plugin> <!-- Don't deploy gwt-user jar to GAE --> <artifactId>maven-clean-plugin</artifactId> <version>2.3</version> <executions> <execution> <id>default-clean</id> <phase>clean</phase> <goals> <goal>clean</goal> </goals> </execution> <execution> <id>remove-gwt-user-jar</id> <phase>package</phase> <goals> <goal>clean</goal> </goals> <configuration> <excludeDefaultDirectories>true</excludeDefaultDirectories> <filesets> <fileset> <directory>${project.build.directory}/${project.build.finalName}/WEB-INF/lib</directory> <includes> <include>gwt-user*jar</include> </includes> </fileset> </filesets> </configuration> </execution> </executions> </plugin>
It should be noted that this is only an issue for Maven projects. Google Plugin for Eclipse has long excluded gwt-user.jar from WEB-INF/lib, so standard GPE projects don’t deploy it to App Engine. However, GPE Maven projects allow Maven to manage the classpath, so you’ll need the clean snippet above in your POM to exclude gwt-user from deployment.
A proposed fix is to enhance the gwt-maven-plugin’s copyWebapp feature (which, ironically enough, was contributed by Google) to exclude gwt-user*jar from the copy. Until then, use the clean snippet above or enable jar splitting.
Matteo Galletti (@Magallo79) said
What about gwt-dev.jar? I create a war file to deploy with Tomcat. When I use Goowgle Web Toolkit->Deploy module from the context menu the gwt-dev.jar is copied in the WB-INF/lib directory and then it is included in the war file. How can exclude it?
David Chandler said
Hi Matteo, you can just add another include tag with gwt-dev*jar.