|
Strutsフレームワーク
|
| Installing Struts with your servlet container |
|
| Strutsをサーブレットコンテナにインストールする |
- In the steps below,
$WAS_HOME refers to the directory in which you
have installed WebSphere Application Server, and $STRUTS_HOME is the
directory in which you unpacked the Struts binary distribution.
- 以下の記述で
$WAS_HOME は、WebSphereアプリケーションサーバーを
インストールしたディレクトリー、$STRUTS_HOME は
Strutsのバイナリ配布版を展開したディレクトリーを指します。
- WebSphere before 3.5.2 did not support JSP 1.1 and Servlet 2.2, which
made it difficult to get Struts functioning without massive code changes.
Please upgrade to 3.5.2 (3.5 with FixPack 2) before attempting to use
Struts. See http://www.ibm.com/software/webservers/appserv/efix.html
for download and install instructions on FixPack 2 for WebSphere 3.5
- 3.5.2以前のWebSphereはJSP 1.1 と Servlet 2.2をサポートしていないため、
Strutsを動作させるためには非常に多くのコードの変更を必要とします。
ぜひStrutsを利用する前に3.5.2へのアップグレード(3.5にFixPack 2を適用する)を行ってください。
http://www.ibm.com/software/webservers/appserv/efix.html
のWebSphere 3.5 FixPack 2のダウンロード方法、インストール方法を参照してください。
- Warning: Struts will not work with WebSphere 3.5.2 out of the box. Fixes
expected to be in WebSphere 3.5.3 (not released at time of writing) should
correct this. However, you can successfully get WebSphere 3.5.2 working
with Struts.
- 注意: WebSphere 3.5.2でStrutsを動作させるためには一部修正が必要となります。
WebSphere 3.5.3 (このドキュメント記述時にはまだリリースされていません)
ではこの問題は修正されているはずです。
しかし、WebSphere 3.5.2 で Strutsを起動させることは可能です。
- Make sure the WebSphere Application Server is started. Under Windows
NT/2000, it's the "IBM WS AdminServer" service.
- WebSphere Application Serverが起動していることを確認します。
Windows NT/2000の場合、"IBM WS AdminServer" サービスがこれに該当します。
- Start the WebSphere Administrative Console.
- WebSphere 管理コンソールを起動します。
- Once it's started, select "Convert a War File" from the tasks toolbar
option, or from the Console->Tasks menu. This will cause a "Convert War
File" Wizard dialog to appear.
- Administrative コンソールが起動したら、 "Convert a War File"を
ツールバー上のウィザードボタンのオプションまたはコンソール->タスクから選択します。
"Convert War File" ウィザードダイアログが表示されます。
- Select a Servlet Engine to host the web application that will result
from converting the War file, e.g. "Default Servlet Engine", by expanding
the tree control under Nodes. Press the Next button.
- Warファイルを展開して生成したWebアプリケーションを動作させるサーブレットエンジン
(例. "Default Servlet Engine")をツリーコントロールを展開して選択し、"次へ"ボタンを押します。
- Select a Virtual Host to associate the resulting web application with,
e.g. "default host". Press the Next button.
- 登録するWebアプリケーションに関連付ける仮想ホスト(例. "default host")を選択し、
"次へ"ボタンを押します。
- Press the Browse button and choose the
$STRUTS_HOME/webapps/struts-example.war. Press the Next button
- "Browse"ボタンを押し、
$STRUTS_HOME/webapps/struts-example.warを選択して、
"次へ"ボタンを押します。
- Select a destination directory for the resulting web application, e.g.
$WAS_HOME/hosts/default_host. Press the Next button
- 登録するWebアプリケーションリソースの対象ディレクトリ (例.
$WAS_HOME/hosts/default_host)
を選択し、"次へ"ボタンを押します。
- Enter a "Web Application Web Path", e.g. struts-example, and a "Web
Application Name", e.g. struts-example. Press the Finish button.
- "Web Application Web Path" (例. struts-example)と "Web Application Name" (例. struts-example)
を入力し、"終了"ボタンを押します。
- You should, after a lengthy pause, get a message box with the text
Command "convert war file" completed successfully. Press Ok.
- ある程度待たされた後、「コマンド"warfile.convert"は正常に終了しました。」 と表示された情報ダイアログが
表示されるはずです。OKを押してください。
- You now need to add jaxp.jar and a jaxp compatible parser, e.g.
parser.jar from JAXP 1.0.1 to the struts-example web application's
servlets directory, e.g.
$WAS_HOME/AppServer/hosts/default_host/struts-example/servlets
- JAXP 1.0.1からjaxp.jar とjaxpに互換性のあるパーサー(例. parser.jar)を
struts-example Webアプリケーションのサーブレットのディレクトリ
(例.
$WAS_HOME/AppServer/hosts/default_host/struts-example/servlets)に配置します。
- At this point, if WAS 3.5.2 correctly implemented Servlet 2.2, all
would be fine. However, WAS 3.5.2 returns null for calls to
ServletContext.getResource(String) or
ServletContext.getResourceAsStream(String). This manifests itself as an
exception in the application server stdout log, e.g.
default_server_stdout.log.
- WAS 3.5.2 がServlet 2.2の仕様に完全に準拠していれば問題はないはずなのですが、
WAS 3.5.2 は
ServletContext.getResource(String) または、
ServletContext.getResourceAsStream(String)をコールするとnullをリターンします。
これはアプリケーションサーバーのstdoutログ(例. default_server_stdout.log.)内の
exceptionを見れば明らかです。
- Warning: Don't be fooled by the fact that the web application starts
successfully from the Admin Console. It actually doesn't. The Admin
Console is lying. If you try to access the webapp
e.g.
http://localhost/struts-example/ it will fail.
- 注意: 管理コンソールからのWebアプリケーションの起動が成功しても、それを鵜呑みにしないでください。
実際には正常に起動していません。管理コンソールは嘘をつきます。
Webアプリケーション(例.
http://localhost/struts-example/)にアクセスしても失敗します。
- At this point, you need to patch the Struts source. There are three
places
getResourceAsStream is called:
- Strutsのソースを修正する必要があります。
getResourceAsStream をコールしている
以下の3箇所を修正してください。
ResourceTag.doStartTag()
ActionServlet.initMapping()
PropertyMessageResources.loadLocale(String)
of these, ActionServlet is the most important.
ResourceTag.doStartTag()
ActionServlet.initMapping()
PropertyMessageResources.loadLocale(String)
中でも ActionServlet が一番重要です。
// Acquire an input stream to our configuration resource
InputStream input = getServletContext().getResourceAsStream(config);
to
// Acquire an input stream to our configuration resource
InputStream input = new
java.io.FileInputStream(getServletContext().getRealPath(config));
// Acquire an input stream to our configuration resource
InputStream input = getServletContext().getResourceAsStream(config);
を以下のように変更します。
// Acquire an input stream to our configuration resource
InputStream input = new
java.io.FileInputStream(getServletContext().getRealPath(config));
- Make similar changes to the other classes if necessary.
- 必要があれば他のクラスにも同様の変更を行ってください。.
- Recompile ActionServlet and copy the
.class file to
$WAS_HOME/AppServer/hosts/default_host/struts-example/servlets/
org/apache/struts/action/ActionServlet.class
- ActionServletをリコンパイルし、
.class ファイルを
$WAS_HOME/AppServer/hosts/default_host/struts-example/servlets/
org/apache/struts/action/ActionServlet.class
にコピーします。
- Another bug with WAS 3.5.2's classloaders is that Class.getResource()
wont load a resource from a jar, so you must copy
$STRUTS_HOME/lib/struts-config_1_0.dtd
to
$WAS_HOME/AppServer/hosts/default_host/struts-example/servlets/org/apache/struts/resources/struts-config_1_0.dtd
or be connected to the Internet to fetch the dtd from the jakarta web site.
- WAS 3.5.2のクラスローダーには Class.getResource() が jar からリソースをロードできないというバグがあるため、
$STRUTS_HOME/lib/struts-config_1_0.dtd
を
$WAS_HOME/AppServer/hosts/default_host/struts-example/servlets/org/apache/struts/resources/struts-config_1_0.dtd
にコピーするか、インターネットに接続し、jakarta WEBサイトのDTDを参照できるようにしてください。
- Start your webapp in the Admin Console
- 管理コンソール内のWebアプリケーションを起動します。
- Test the example application by loading the following URL in your
browser of choice: http://localhost/struts-example/"
- ブラウザから次のURLをロードし、サンプルアプリケーションをテストします。
http://localhost/struts-example/
インストールへ戻る
|
|