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

GWT/GAE: Deployment an application on external server JBOSS

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

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:

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

…so deploy 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 JBOSS like jboss-4.2.3.GA\server\default\deploy\
  • Copy the content of folder huojavagwttest3\war in the newly created folder jboss-4.2.3.GA\server\default\deploy\huojavagwttest3:
  • Start the server JBOSS 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 Jboss 4.2 (Apache Tomcat 6.0, 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 ….jboss-4.2.3.GA\server\default\deploy\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 JBOSS jboss-4.2.3.GA\server\default\deploy\:
  • Start the server JBOSS in Eclipse due to the “Servers” view:

    11:30:32,843 INFO  [Server] Starting JBoss (MX MicroKernel)...
    11:30:32,843 INFO  [Server] Release ID: JBoss [Trinity] 4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)
    ...
    11:30:54,509 INFO  [TomcatDeployer] deploy, ctxPath=/huojavagwttest3, warUrl=.../tmp/deploy/tmp2307776124304356332huojavagwttest3-exp.war/
    ...
    11:31:01,475 INFO  [ContextLoader] Root WebApplicationContext: initialization completed in 3533 ms
    11:31:02,305 INFO  [Http11Protocol] Démarrage de Coyote HTTP/1.1 sur http-127.0.0.1-8080
    11:31:02,585 INFO  [AjpProtocol] Starting Coyote AJP/1.3 on ajp-127.0.0.1-8009
    11:31:02,605 INFO  [Server] JBoss (MX MicroKernel) [4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)] Started in 29s:752ms
    
  • 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

1 thought on “GWT/GAE: Deployment an application on external server JBOSS”

Leave a Reply

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.

Related Post