Deploying the GWT project with Maven

In this section, we will compile, package, and deploy the GWT web project to WildFly 8.1 with the Maven build tool. The pom.xml file is similar to the one used for the project generated on the command line and imported into Eclipse. The Errai (a GWT-based framework) dependencies are also included. The packaging for gwt-jboss-ajax artifactId is war. The GWT version should be 2.6.0. Refer to the following code to accomplish this:

<properties>
  <version.com.google.gwt>2.6.0</version.com.google.gwt>
</properties>

Specify the output directory for the Maven WAR plugin configuration as the WildFly 8.1 deployments directory, as follows:

<outputDirectory>C:wildfly-8.1.0.Finalstandalonedeployments</outputDirectory>

The GWT user library for GWT widgets and panels and support for Ajax is a required dependency with scope as compile. Refer to the following code for this:

<dependency>
  <groupId>com.google.gwt</groupId>
  <artifactId>gwt-user</artifactId>
  <scope>compile</scope>
</dependency>

The GWT development dependency is required as it supports the Java-to-JavaScript compiler with scope as provided. Refer to the following code for this dependency:

<dependency>
  <groupId>com.google.gwt</groupId>
  <artifactId>gwt-dev</artifactId>
  <scope>provided</scope>
</dependency>

GWT validation requires the Hibernate Validator and the Validation API. In addition to the Maven compiler plugin and the Maven WAR plugin, the GWT plugin is required to compile the client-side Java to JavaScript.

Not all the dependencies included in pom.xml are used in the example application of this chapter. Before we can run pom.xml, we need to modify the directory structure of the GWT project to the standard directory layout for a Maven project with the src/main/java directory for the application Java sources and the src/main/webapp directory for the web application sources, as shown in the following screenshot. Create the src/main/java and src/main/webapp directories and copy the Java source code to the src/main/java directory and the web application source code to the src/main/webapp directory.

Deploying the GWT project with Maven

Next, run the Maven build tool. Right-click on pom.xml and select Run As | Maven install, as shown in the following screenshot:

Deploying the GWT project with Maven

The GWT project gets compiled and packaged to gwt-jboss-ajax.war , as shown in the following screenshot. The compiled JavaScript file org.jboss.gwt.CatalogForm.nocache.js gets added to the org.jboss.gwt.CatalogForm directory, which is included in the relative path in the script tag in the CatalogForm.html hosted page:

Deploying the GWT project with Maven

Start the WildFly 8.1 server. The gwt-jboss-ajax.war gets deployed to the server. The gwt-jboss-ajax.war is shown deployed in the Administration Console of WildFly in the following screenshot:

Deploying the GWT project with Maven
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset