JavaBlog.fr / Java.lu DEVELOPMENT,GAE,Google,GWT,Java GWT/GAE: Deployment an application on external server TOMCAT

GWT/GAE: Deployment an application on external server TOMCAT

In this mini-post, we will deploy an application/project containing a simple GWT module on external server TOMCAT.

Javascript generation of a GWT application
As a reminder, to compile a Web application Eclipse project:
The

…the ouputs in console would be:

Compiling module com.ho.gwt.test3.module31.Huojavagwttest3
   Compiling 6 permutations
      Compiling permutation 0...
      Compiling permutation 1...
      Compiling permutation 2...
      Compiling permutation 3...
      Compiling permutation 4...
      Compiling permutation 5...
   Compile of permutations succeeded
Linking into C:\MyFiles\Development\Java\dev\huojavagwttest3\war\huojavagwttest3
   Link succeeded
   Compilation succeeded -- 60,023s

…so, after the GWT compilation, the folder war of the Web application Eclipse project will contain the result of the compilation:

Organization of a Web application
The structure of a Web application is generally as follows:

  • webapps/huojavagwttest3: this is the root of the project, containing the default HTML pages, JavaScript files and images … all static resources of a web application.
  • webapps/huojavagwttest3/WEB-INF: contains the web.xml file describing the server side of the application including the name of servlets that are loaded.
  • webapps/huojavagwttest/WEB-INF/classes: contains the binaries of the web application (java bytecode)
  • webapps/huojavagwttest/WEB-INF/lib: contains the java libraries that are used by the project (GWT librarires).

…so webapps is the root directory of our deployments.

Method 1: Manual deployment of a GWT application

  • Create a folder huojavagwttest3 in the deployment’s folder of TOMCAT like TomCat\webapps\
  • Copy the content of folder huojavagwttest3\war in the newly created folder TomCat\webapps\huojavagwttest3:
  • Start the server TOMCAT in Eclipse due to the “Servers” view:
  • Check the deployment with opening the URL http://localhost:8080/huojavagwttest3/Huojavagwttest3.html or http://localhost:8080/huojavagwttest3/

Method 2: Deployment of a GWT application as WAR file
The deployment of a web application is usually based on the use of WAR. WAR is a zipped archive that simplifies deployment on various application servers. Its structure is the same as that of the directory file created for the previous deployment. Rather than create an ANT script, we will create a new Eclipse project dedicated to the deployment:

  • Creating the Eclipse project:
    Create an Eclipse project deployment type “Dynamic Web Project” named huojavagwttest3_deploy. This project name is different from the project containing the code GWT.

    Select Target Runtime Apache Tomcat 6.0 (Jboss 4.2, Jboss 4.0).

    The Eclipse project huojavagwttest3_deploy has been created.

  • Adding GWT library and project resources:
    In the Eclipse project created, copy manually the following resources (these copies are feasible via ANT, MAVEN, BATCH…):

    • the library gwt-servlet.jar from huojavagwttest3\war\WEB-INF\lib\ to huojavagwttest3_deploy\WebContent\WEB-INF\lib\. Verify the presence of this library by right clicking on the project huojavagwttest3_deploy and choose Properties from the menu, then select Java Build Path and under Web App Libraries:
    • the resources from projet GWT named huojavagwttest3 in the folder huojavagwttest3\war to the project Dynamic Web Project named java_gwt_test2_deploy in the folder WebContent. Normally, when creating the Eclipse project file web.xml is created automatically like:
      <?xml version="1.0" encoding="UTF-8"?>
      <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
        <display-name>huojavagwttest3_deploy</display-name>
        <welcome-file-list>
          <welcome-file>index.html</welcome-file>
          <welcome-file>index.htm</welcome-file>
          <welcome-file>index.jsp</welcome-file>
          <welcome-file>default.html</welcome-file>
          <welcome-file>default.htm</welcome-file>
          <welcome-file>default.jsp</welcome-file>
        </welcome-file-list>
      </web-app>
      

    Usually, it should be changed to match our web application GWT, yet, the following copies of resources avoid the need of adjust this file web.xml:

    • huojavagwttest3\war\huojavagwttest3 to huojavagwttest3_deploy\WebContent\huojavagwttest3
    • huojavagwttest3\war\favicon.ico to huojavagwttest3_deploy\WebContent\favicon.ico
    • huojavagwttest3\war\Huojavagwttest3.html to huojavagwttest3_deploy\WebContent\Huojavagwttest3.html
    • huojavagwttest3\war\Huojavagwttest3.css to huojavagwttest3_deploy\WebContent\Huojavagwttest3.css
    • huojavagwttest3\war\WEB-INF\deploy to huojavagwttest3_deploy\WebContent\WEB-INF\deploy
    • huojavagwttest3\war\WEB-INF\classes to huojavagwttest3_deploy\WebContent\WEB-INF\classes
    • huojavagwttest3\war\WEB-INF\appengine-web.xml to huojavagwttest3_deploy\WebContent\WEB-INF\appengine-web.xml
    • huojavagwttest3\war\WEB-INF\logging.properties to huojavagwttest3_deploy\WebContent\WEB-INF\logging.properties
    • huojavagwttest3\war\WEB-INF\web.xml to huojavagwttest3_deploy\WebContent\WEB-INF\web.xml

  • War generation:
    Generation of WAR file from the deployment project of type “Dynamic Web Project” huojavagwttest3_deploy via “Export -> WAR file” with choice of name and location of the WAR like ….\TomCat\webapps\huojavagwttest3.war:

    The name of the WAR must have the same name of the GWT project to avoid problems of access to services on the remote server huojavagwttest3.war. This WAR is copied in the root deployment folder of TOMCAT TomCat\webapps\:
  • Start the server TOMCAT in Eclipse due to the “Servers” view:

    INFO: Starting Servlet Engine: Apache Tomcat/6.0.18
    22 août 2012 23:55:11 org.apache.catalina.startup.HostConfig deployWAR
    INFO: D�ploiement de l'archive huojavagwttest3.war de l'application web
    ...
    INFO: Server startup in 7225 ms
    
  • Check the deployment with opening the URL http://localhost:8080/huojavagwttest3/Huojavagwttest3.html or http://localhost:8080/huojavagwttest3/

In this step, we have learned to deploy a GWT application in two ways:

  • Mode exploded: Manually deployment of a web application / GWT whose files are not in a WAR,
  • Mode packaged: Deployment of a web application / GWT with Eclipse into WAR.

That’s all!!!

Best regards,

Huseyin OZVEREN

Leave a Reply

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.

Related Post

Documentum : Audit trail entries dm_audittrail / SessionConfig / application_codeDocumentum : Audit trail entries dm_audittrail / SessionConfig / application_code

Hi, After my previous posts concerning the Documentum audit trail entries (dm_audittrail) http://www.javablog.fr/documentum-creation-of-audit-trail-entries-dm_audittrail.html and http://www.javablog.fr/deleting-of-audit-trail-entries-dm_audittrail.html, here, I would like to expose a solution in order to force content server to