Ubuntu ServerにBlazeDSをセットアップする
AIRのアプリケーションサーバを構築するための環境設定の確認として、BlazeDSをセットアップする。
環境はデスクトップ機にUbuntuをインストール。
- Ubunto server 8.04.2 LTS
- Dell Inspiron Desktop 531
- AMD Athlon 64 x2 デュアルコア・プロセッサ 5000+
- RAM 2GB
Xwindowがあったほうがやっぱり楽かな、とdesktopをインストール。
apacheをパッケージ・マネージャーからインストール。apache2(2.2.8-1)を入れます。
JAVAの実行環境が必要なので、こちらもパッケージ・マネージャーからインストール。sun-java6-jdk(6-07-3)を入れます。
今回確認したいのは、設定済みtomcatが含まれているBlazeDS-Turnkey
なので、tomcatはそちらで。
ダウンロードサイト(参照)からblazeds-turnkey-3.2.0.3978.zipを落としてきて、ホームディレクトリに展開しました。以下のものが含まれています。
インストールガイド(参照)では
To install BlazeDS in the integrated Tomcat configuration:
1. Read the BlazeDS Release Notes for known issues and any late-breaking information.
2. Unzip the ZIP file to a local directory on your file system.
3. Make sure that the machine you are installing on has a Java Development Kit (JDK) installed and a JAVA_HOME environment variable.
4. To start BlazeDS on Microssoft Windows, open a command window, navigate to install_root/tomcat/bin, and enter the catalina start command. On OS X, UNIX, and Linux, enter ./catalina start. Optionally, on Windows you can navigate to the install_root/tomcat/bin in Windows Explorer and double-click the startup.bat icon.
となっていて、まず、JAVA_HOMEの環境変数を変更します。
環境変数がうまくないと、catalina.shを起動する際に、環境変数が設定されていないと、以下のようなエラーが返ってきました。
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program
JAVAのバージョンは返ってくるので、JAVAはあるのに・・と思いきや、pathはJDKに向かってない...
$ java -version
java version "1.6.0_07"
$ which java
/usr/bin/java
どうすれば環境変数を変えれるのかわからなくて四苦八苦しましたが、Sunのホームページを参考に(参照)
~/.profileに、パッケージ・マネージャーで入れたJDKのパスを書き加えました。
PATH=/usr/lib/jvm/java-6-sun/bin:$PATH
export JAVA_HOME=/usr/lib/jvm/java-6-sun/
JAVA_HOMEを設定して、(install_root)/tomcat/binにある、catalina.shを実行。
これでインストールができた状態(たぶん)。
動作確認は、ガイドでは以下のようになってます。
Running the Test Drive with the integrated Tomcat install
In addition to the BlazeDS WAR file, the BlazeDS download includes a version of Tomcat (6.0.14) with a series of web applications fully configured with BlazeDS. To run the test drive after downloading and expanding the integrated Tomcat install:
1. Start Tomcat (startup.bat or startup.sh in /blazeds/tomcat/bin).
2. The BlazeDS sample applications use an HSQLDB database that is installed in the install_root/sampledb directory. To start the sample database:
* Open a command prompt and go to the install_root/sampledb directory.
* Run startdb.bat (Windows) or startdb.sh (Unix-based systems).
3. Open a browser and access the samples home page:
http://localhost:8400/samples/
4. Take the test drive!
次のサイトも参考に(参照)
まず、(install_root)/tomcat/binにある、startup.shを実行。(終了は、shutdown.sh)
tomcatがうまく実行できれば、
$ ./startup.sh
Using CATALINA_BASE: (install_root)/tomcat
Using CATALINA_HOME: (install_root)/tomcat
Using CATALINA_TMPDIR: (install_root)/tomcat/temp
Using JRE_HOME: /usr/lib/jvm/java-6-sun/
http://localhost:8400/にアクセスすると、BlazeDSのwelcomeページが開きます。
サンプルを動かすには、(install_root)/sampledbにある、startdb.shを実行。
サンプルページのキャプションには
This test drive consists of a series of eight samples
と8つある風ですが、Take the test driveに7つ、その他に4つ用意されています。
BlazeDS Test Drive
Sample 1: Accessing data using HTTPService
Sample 2: Accessing data using Web Services
Sample 3: Accessing data using Remoting
Sample 4: Flex Programming Model 101
Sample 5: Updating Data
Sample 6: Publish/Subscribe Messaging (Data Push Use Case)
Sample 7: Publish/Subscribe Messaging (Collaboration Use Case)
Other Samples
- Inventory Management
- Trader Desktop
- Collaboration Dashboard
- Runtime Configuration
クライアントにflashが入っていれば、サンプルを確認できます。