Installing Google Web Toolkit: Introducing the Google App Engine

Welcome to the second part of a series on Google Web Toolkit. In this part you’ll learn how to handle the Google App Engine and deploy your project to a production server.

In the first part of this tutorial here: http://www.devshed.com/c/a/AJAX/Installing-Google-Web-Toolkit/ you learned how to start working with Google Web Toolkit. The article covered installing it in your Ubuntu computer, configuring your Java settings, installing Apache Ant and finally running the application in the development mode (local server).

However, the end result of your Google Web Toolkit project is that it should be deployed to a production server so that it can be accessed by Internet users. This tutorial uses the basic example included with the Google Web Toolkit project, which is the “web application starter project,” along with Java as the programming language.

Introducing the Google App Engine

The good news for GWT developers is that Google has released the Google App Engine, which is a platform for hosting web applications created using Google Web Toolkit. The server can execute Java Code or other supported programming languages like Python.

If you are going to deploy the project in a server that does not support the execution of Java code (or Java Runtime environment) in the server side, you will get the following error:

Server replies:
An error occurred while attempting to contact the server. Please check your network connection and try again.

For example, you will get “Remote Procedure Call- Failure” if you use the web application starter project included in the Google Web Toolkit, as shown below:

To successfully deploy the web application starter project in a hosting environment, you need a platform that supports the Java runtime environment. The recommended solution is to use Google App Engine. It works by:

1. Registering your application with Google. In this case, you need to have a Google account.

2. Providing you with an Application ID, which you will use to successfully upload your files to Google App Engine server.

3. Providing you a freely accessible sub-domain (using the appspot.com domain) which you can use to access your web application with a web browser.

For example, if your application identifier is mygooglewebapps, it is accessible at mygooglewebapps.appspot.com

Since the use of Google Apps Engine is free for the developer, it is limited in terms of CPU, storage, mail usage and other features.To remove quota restrictions, Google Apps Engine allows you to “Enable Billing,” at which point you can use it beyond what is provided for “free” on the quota plan.

Google Apps Engine even allows you to host your application on another domain, like www.example.com. It is a relatively simple procedure; you just need to “Add Domain.”

For details on Google App Engine, you can read this document: http://code.google.com/appengine/docs/whatisgoogleappengine.html

Things to do before uploading project to Google Apps Engine

Assuming you already have a Google account, follow the rest of the procedures below to prepare your applications to be uploaded to Google Apps Engine, so that you can run your applications not only in the development mode, but in a real production server environment.

Step 1. Log in using Google account in http://appengine.google.com/

Step 2. Click the button that will let you create a new application, e.g “Create an Application.”

Step 3. Under “Application Identifier,” enter your desired application identifier, e.g codexm-apps. Click “Check availability” to find out if the identifier is available.

Step 4. Under “Application Title,” enter the title of your Application, e.g “Codex M Google Web Apps.” Just leave the rest of the options at their default settings.

Step 5. Finally, click “Create Application.”

Step 6. Take note of your application identifier, as you will be using it later.

Try clicking the “dashboard” link. You will see a warning note: “You need to upload and deploy an application before you can make a web history. Read about using appcfg to upload and deploy one.”

To upload files successfully to Google Apps Engine, you need to use a utility tool called “appcfg.”

This is available in a separate developer package called “Google App Engine SDK for Java” (for Java-based developers). You can download it here: http://code.google.com/appengine/downloads.html

Download the package to your desktope.g appengine-java-sdk-1.3.7.zip

You need to unzip the package after downloading.

IMPORTANT: You need to ensure that before proceeding with the rest of the preparations for uploading your web application to Google Apps Engine, it works completely in your Google Web Toolkit development server.

Also, you need to have compiled the source code for deployment before proceeding further. Refer to the first part of this tutorial: http://www.devshed.com/c/a/AJAX/Installing-Google-Web-Toolkit/1/

Creating the appengine-web.xml file and copying the required files

Every web application to be uploaded to the Google Apps engine requires you to have an appengine-web.xml file that will be uploaded along with your existing files.

You need to create this file. Follow the steps below:

Step 1. Go to Applications -> Accessories -> gedit Text editor.

Step 2. In the blank space of the text editor, paste the following XML code below:

<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
  <application>YOUR APPLICATION IDENTIFIER HERE</application>
  <version>1</version>
</appengine-web-app>

Step 3. Replace “YOUR APPLICATION IDENTIFER HERE” with your identifier provided by Google Apps engine during the registration of your application.

Step 4. Save it as appengine-web.xml

Step 5. Save it to MyWebApp/war/WEB-INF/

Sample screen shot of this XML configuration file in WEB-INF directory:

Step 6. In the appengine-java-sdk-1.3.7 folder, go to /lib/impl and look for appengine-api.jar

Step 7. Copy appengine-api.jar to your GWT web application project MyWebApp/war/WEB-INF/lib

After copying this file, there will now be two JAR (Java archive) files in /WEB-INF/lib:  appengine-api.jar and gwt-servlet.jar.

{mospagebreak title=Uploading Files to Google Apps Engine Server}

Now that the preparation is complete, you are ready to upload your GWT project to Google Apps engine. So what do you need to upload? You will need to upload only the contents of your war directory, which are as follows:

Go through the checklist below before uploading, to make sure you have the following files:

  • appengine-web.xml in MyWebApp/war/WEB-INF (make sure it uses the correct Application identifier).

  • web.xml in MyWebApp/war/WEB-INF

  • appengine-api.jar in MyWebApp/war/WEB-INF/lib

To upload the files, follow the steps below:

Step 1. Open the Linux terminal.

Step 2. You need to change the directory to your Ubuntu Desktop first, and then go inside the “bin” folder of appengine-java-sdk-1.3.7 directory.

Commands:

codex-m@codex-m-desktop:~$ cd Desktop
codex-m@codex-m-desktop:~/Desktop$ cd appengine-java-sdk-1.3.7
codex-m@codex-m-desktop:~/Desktop/appengine-java-sdk-1.3.7$ cd bin
codex-m@codex-m-desktop:~/Desktop/appengine-java-sdk-1.3.7/bin$

The purpose of getting into the bin directory in appengine-java-sdk-1.3.7 is to execute the script appcfg.sh.

This script will let you upload files from the local server to Google Apps engine server. The actual syntax of the command is (take note of the dot before the appcfg.sh):

./appcfg.sh update [linux path to your war directory]

For example, if your Linux path to your war directory is : /home/codex-m/Desktop/gwt-2.0.4/MyWebApp/war then the command will be:

./appcfg.sh update /home/codex-m/Desktop/gwt-2.0.4/MyWebApp/war

Using the Linux prompt (in Terminal, bolded is the actual command to be executed):

codex-m@codex-m-desktop:~/Desktop/appengine-java-sdk-1.3.7/bin$ ./appcfg.sh update /home/codex-m/Desktop/gwt-2.0.4/MyWebApp/war

Press the enter key and it will start uploading the files. It will also show the progress of the uploading process:

Reading application configuration data…
09 24, 10 11:41:36 PM com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml
INFO: Successfully processed /home/codex-m/Desktop/gwt-2.0.4/MyWebApp/war/WEB-INF/appengine-web.xml
2010-09-24 23:41:36.842:INFO::Logging to STDERR via org.mortbay.log.StdErrLog
09 24, 10 11:41:40 PM com.google.apphosting.utils.config.AbstractConfigXmlReader readConfigXml
INFO: Successfully processed /home/codex-m/Desktop/gwt-2.0.4/MyWebApp/war/WEB-INF/web.xml
Beginning server interaction for codex-m…
0% Creating staging directory
5% Scanning for jsp files.
20% Scanning files on local disk.
25% Initiating update.
Email: codex_m@yahoo.com
Password for codex_m@yahoo.com: 
28% Cloning 32 static files.
31% Cloning 44 application files.
40% Uploading 2 files.
52% Uploaded 1 files.
61% Uploaded 2 files.
68% Initializing precompilation…
90% Deploying new version.
95% Will check again in 1 seconds.
98% Will check again in 2 seconds.
99% Will check again in 4 seconds.
99% Will check again in 8 seconds.
99% Will check again in 16 seconds.
99% Will check again in 32 seconds.
99% Closing update: new version is ready to start serving.
99% Uploading index definitions.
 
Update completed successfully.

IMPORTANT: Be prepared to enter your Google account login information (in e-mail and password); it is needed to proceed with the uploading, as shown above. The uploading process might take some time, so you need to wait until it is successfully uploaded and you see the text “Update completed successfully.”

Now launch your browser, and then browse to the sub-domain URL in the appspot.com domain where you can see your application — e.g. http://mygooglewebapps.appspot.com

Example:

[gp-comments width="770" linklove="off" ]
antalya escort bayan antalya escort bayan