TurboManage

David Chandler's Journal of Java Web and Mobile Development

  • David M. Chandler


    Web app developer since 1994 and former Developer Advocate with Google now residing in Colorado. Besides tech, I enjoy landscape photography and share my work at ColoradoPhoto.gallery.

  • Subscribe

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 241 other followers

  • Sleepless Nights…

    March 2011
    S M T W T F S
    « Feb   Apr »
     12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
  • Blog Stats

    • 865,597 hits

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.

Advertisements

2 Responses to “GWT + Maven + GAE gotcha”

  1. 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?

  2. Hi Matteo, you can just add another include tag with gwt-dev*jar.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: