GWT apps using Maven and Eclipse

Used to be that getting a GWT project together using Maven and Eclipse was a tedious and frustrating task. Times have changed so that the process is quite a bit easier.

Eclipse 3.5
Google plugin for Eclipse 1.32
gwt-maven-plugin 1.2
Maven plugin for Eclipse 0.10.0

Install the Google plugin for Eclipse into eclipse specifying the update site url through Eclipse’s Help->Install New Software->Add… and specify the url

If you have a previous version of the m2 plugin you will need to uninstall it as the 0.10.0 version will not upgrade properly otherwise. Install the Maven plugin.

From Eclipse, create a new Maven project:
File->New->Other->Maven->Maven Project

Do not check Create a simple project as we want to do archetype selection, but fill the rest in as you see fit then click Next.

Select either Nexus Indexer or All Catalogs as the catalog, then scroll down the list looking for a Group Id of org.codehaus.mojo with an Artifact Id of gwt-maven-plugin and choose the highest version (1.2 at this time) then click Next.

Fill in your Group Id and your Artifact Id and the rest of the fields and click Finish.

The next set of the instructions are mostly from

In Eclipse, select your project then choose Project->Properties->Google->Web Toolkit and click Use Google Web Toolkit.

Then click on Web Application (Project->Properties->Google->Web Application and change the War Directory to src/main/webapp and uncheck Launch and deploy from this directory then click OK.

Open the pom.xml file under your project and check some Properties values. You want gwt-version to be 2.0.3 and maven.compiler.source and maven.compiler.source to be 1.6.

Right click on your project and select Run As->Maven Clean, then Run As->Maven Package.

Right-click your project and select Run As->Web Application. The first time you do this, you’ll have to select the location of the exploded WAR directory (by default it should be /target/).

If everything works out fine, you are now running in hosted mode. Click on the Development Mode view tab down where the Console tab is and copy and paste the URL shown there into a browser to see your app running.

GWT development/hosted mode is now running out of the WAR directory created by Maven. You can step through and debug your code as usual. If you make changes, it is sometimes possible to have your running application reflect those changes without restarting your debugging session:

  • If you change client-side code, just click Refresh in your browser.
  • To have server-side code changes reflected, your project’s build output path must be set to /target//WEB-INF/classes (Project properties > Java Build Path > Source > Default output folder). Then, when you change a server-side class click the Reload web server button in the Development Mode view.
  • If you change resource or configuration files in your WAR directory (HTML, JSP, CSS, etc.), you’ll have to terminate the launch configuration, run mvn clean package, and then launch again.

7 Replies to “GWT apps using Maven and Eclipse”

  1. It would have been interesting to read on how to modify the pom file to skip using the war folder. The Google eclipse plugin supports this and it should not be necessary to have a war folder in your tree structure.

  2. Thanks man, this sorted it out for me. I was just getting frustrated about all this when I found your page

  3. Perfect!!!

    The step tha I forgot was:
    Right click on your project and select Run As->Maven Clean, then Run As->Maven Package.

    Thank you!!

  4. Once I went through all those steps I can run my application using Run As>Web Application but my client-side changes are not reflected without compiling (using gwt-maven-plugin gwt:compile or the compile function of the GWT Plugin for Eclipse).
    Actually if I execute gwt:clean of the gwt-maven-plugin, which deletes the GWT generated stuff in target/- and if I try to run my application with Run As>Web Application I get in the browser “GWT module ‘mymodule’ may need to be (re)compiled”.
    In fact the GWT automatic compilation seems not to work at all.
    The second problem is that if I run my application using Debug As>Web Application the process does not stop on my breakpoints.
    I guess I made a mistake somewhere but after struggling all day I start to be really frustrated.
    Any ideas would be extremely welcomed. Thanks in advance…

  5. When setting the GWT properties on the project, I had to check the “This project has a WAR directory” box in order to set the “WAR directory” to “src/main/webapp”. Otherwise, I followed your steps exactly. But, when I run the web application I get this error in my console:

    No startup URLs supplied and no plausible ones found — use -startupUrl

    Any thoughts on why? Thanks!

  6. Hello,

    Thanks for the guide steps. I am facing a problem with the gwt-maven-plugin archetype. The Nexus Indexer only returns the 1.3-SNAPSHOT you have any idea why this is?

    Any help will be appreciated.

  7. [WARN] No startup URLs supplied and no plausible ones found — use -startupUrl while run GWT web application from eclipse helios java 1.6 and GWT 2.3.. any ideas

Leave a Reply

Your email address will not be published. Required fields are marked *