Sunday, February 5, 2012

Spring 3.1: GWT Maven Plugin and GWTHandler Integration (Part 4)

Review

In the previous section, we have studied how to generate a simple GWT application using the GWT Maven plugin. We've also learned how integrate Spring and GWT using the GWTHandler library. In this section, we will build and run the application using Maven, and show how to import the project in Eclipse (if you've decided in Part 2 to use command-line based development).


Running the Application

Access the source code

To download the source code, please visit the project's Github repository (click here)

Building with Maven

  1. Ensure Maven is installed
  2. Open a command window (Windows) or a terminal (Linux/Mac)
  3. Run the following command:
    mvn gwt:run
  4. You should see the following output:
    [INFO] Scanning for projects...
    [INFO] ------------------------------------------
    [INFO] Building GWT Maven Archetype
    [INFO]    task-segment: [gwt:run]
    [INFO] ------------------------------------------
    [INFO] Preparing gwt:run
    [INFO] [gwt:i18n {execution: default}]
    [INFO] [gwt:generateAsync {execution: default}]
    [INFO] [gwt:run {execution: default-cli}]
    [ERROR] INFO: Mapped URL path [/greet] onto handler of type [class org.gwtwidgets.server.spring.GWTRPCServiceExporter]
    [ERROR] Feb 5, 2012 2:49:45 PM org.springframework.web.servlet.FrameworkServlet initServlet
    
  5. Note: If the project will not build due to missing repositories, please enable the repositories section in the pom.xml!

Access the Entry page

  1. Follow the steps with Building with Maven
  2. Open a browser
  3. Enter the following URL (8080 is the default port for Tomcat):
    http://127.0.0.1:8888/gwtmodule.html?gwt.codesvr=127.0.0.1:9997
    Or better yet, on the GWT Development Mode window, click on the Launch Default Browser button.
You should see the following page (the popup message will appear when you submit a name):

Import the project in Eclipse

  1. Ensure Maven is installed
  2. Open a command window (Windows) or a terminal (Linux/Mac)
  3. Run the following command:
    mvn eclipse:eclipse -Dwtpversion=2.0
  4. You should see the following output:
    [INFO] Scanning for projects...
    [INFO] Searching repository for plugin with prefix: 'eclipse'.
    [INFO] org.apache.maven.plugins: checking for updates from central
    [INFO] org.apache.maven.plugins: checking for updates from snapshots
    [INFO] org.codehaus.mojo: checking for updates from central
    [INFO] org.codehaus.mojo: checking for updates from snapshots
    [INFO] artifact org.apache.maven.plugins:maven-eclipse-plugin: checking for updates from central
    [INFO] artifact org.apache.maven.plugins:maven-eclipse-plugin: checking for updates from snapshots
    [INFO] -----------------------------------------
    [INFO] Building GWT Maven Archetype
    [INFO]    task-segment: [eclipse:eclipse]
    [INFO] -----------------------------------------
    [INFO] Preparing eclipse:eclipse
    [INFO] [gwt:i18n {execution: default}]
    [INFO] [gwt:generateAsync {execution: default}]
    [INFO] [eclipse:eclipse {execution: default-cli}
    [INFO] Adding support for WTP version 2.0.
    [INFO] -----------------------------------------
    [INFO] BUILD SUCCESSFUL
    [INFO] -----------------------------------------
    
    This command will add the following files to your project:
    .classpath
    .project
    .settings
    target
    You may have to enable "show hidden files" in your file explorer to view them
  5. Open Eclipse and import the project

Maven Issues

If in case you have Maven repository issues, you can always download the depedencies directly from Sonatype OSS for Google GWT.

Conclusion

That's it! We've have successfully completed our GWT and Spring integration. We've learned how to generate a simple GWT project using the GWT Maven plugin, and integrate Spring using the GWTHandler library.

I hope you've enjoyed this tutorial. Don't forget to check my other tutorials at the Tutorials section.

Revision History


Revision Date Description
1 Feb 5 2012 Uploaded tutorial and Github repository

StumpleUpon DiggIt! Del.icio.us Blinklist Yahoo Furl Technorati Simpy Spurl Reddit Google I'm reading: Spring 3.1: GWT Maven Plugin and GWTHandler Integration (Part 4) ~ Twitter FaceBook

Subscribe by reader Subscribe by email Share

5 comments:

  1. Be aware I'm new to Spring and Maven, so there is no telling what I could have done wrong, but I'm sharing here in case anyone else might run across this:

    For some reason (could be the version of SpringSource Tool Suite, etc., I'm using) I had to add a few Maven dependencies (in the pom.xml) to get these final steps of Spring and GWT integration in this tutorial:



    org.springframework
    spring-context
    3.1.1.RELEASE



    org.springframework
    spring-core
    3.1.1.RELEASE



    org.springframework
    spring-web
    3.1.1.RELEASE



    org.springframework
    spring-webmvc
    3.1.1.RELEASE




    net.sf.gwt-widget
    gwt-sl
    1.1

    ReplyDelete
  2. Should the tests work when a "mvn install" is performed ? Currently there is a test failure.

    ReplyDelete
  3. hi, a very nice article.I followed the same steps i got remote procedure call as a failure..what might be the possible mistake i've done..

    Thanks

    ReplyDelete
  4. hai

    i am follwed same steps for integrating spring with gwt but getting failure meassage when we submit

    ReplyDelete
  5. Invalid gwtmodule/rpc/* in servlet mapping

    ReplyDelete