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:
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
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
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
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"?>
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.
blog comments powered by Disqus