リンク 目次 | Deployment| 背景 |
Before describing how to organize your source code directories,
it is useful to examine the runtime organization of a web application.
Prior to the Servlet API Specification, version 2.2, there was little
consistency between server platforms. However, servers that conform
to the 2.2 (or later) specification are required to accept a
Web Application Archive in a standard format, which is discussed
further below.
あなたのソースコードディレクトリの構成をどのようにするか説明する前に、
Webアプリケーションの実行時の構成について調べることは役に立ちます。
Servlet API仕様 2.2版より前では、サーバプラットフォーム間では一貫性はほとんどありませんでした。
しかし、2.2(またはそれ以降)の仕様に適合したサーバでは、
以下に説明する標準形式のWebアプリケーションアーカイブを受け入れることが要求されます。
A web application is defined as a hierarchy of directories and files
in a standard layout. Such a hierarchy can be accessed in its "unpacked"
form, where each directory and file exists in the filesystem separately,
or in a "packed" form known as a Web ARchive, or WAR file. The former format
is more useful during development, while the latter is used when you
distribute your application to be installed.
Webアプリケーションは、標準レイアウトのファイルとディレクトリ階層として定義
されています。
このような階層は、"unpacked"形式としてアクセスされ
それぞれのディレクトリとファイルはファイルシステムで分割されて存在します。
また、"packed"形式は、Webアーカイブ(Web ARchive)またはWARファイルとして知られています。
開発時には前者の形式の方が便利ですが、後者の形式はあなたのアプリケーションを配布して、
インストールするときに使用します。
The top-level directory of your web application hierarchy is also the
document root of your application. Here, you will place the HTML
files and JSP pages that comprise your application's user interface. When the
system administrator deploys your application into a particular server, he
or she assigns a context path to your application (a later section
of this manual describes deployment on Tomcat). Thus, if the
system administrator assigns your application to the context path
/catalog, then a request URI referring to
/catalog/index.html will retrieve the index.html
file from your document root.
あなたのWebアプリケーション階層のトップレベルディレクトリは、
あなたのアプリケーションのドキュメントルートでもあります。
ここは、あたなのアプリケーションのユーザインタフェースを構成するHTMLファイルとJSPページの場所です。
システム管理者が、ある特定のサーバーにアプリケーションを配備するときには、
彼または彼女はコンテキストパス(context path)をあなたのアプリケーションに割り当てます。(Tomcatでの配備についてはこのマニュアルの後のセクションで説明します)。
つまり、システム管理者があなたのアプリケーションをコンテキストパスの/catalog/に割り当てた場合には、要求された/catalog/index.htmlを参照するURIは、ドキュメントルートからindex.htmlファイルを取り出します。
|
| 標準ディレクトリ・レイアウト |
To facilitate creation of a Web Application Archive file in the required
format, it is convenient to arrange the "executable" files of your web
application (that is, the files that Tomcat actually uses when executing
your app) in the same organization as required by the WAR format itself.
To do this, you will end up with the following contents in your
application's "document root" directory:
要求された形式でWebアプリケーションアーカイブファイルを作成することを容易にするために、
あなたのWebアプリケーションの"実行"ファイル
(つまり、アプリケーションの実行時にTomcatが実際に使用するファイル)を、
WARフォーマットが要求するものと同じディレクトリ構成にしておくと便利です。
これを行うためには、最終的に以下の内容をあなたのアプリケーションの
"ドキュメントルート"ディレクトリに置きます。
- *.html, *.jsp, etc. - The HTML and JSP pages, along
with other files that must be visible to the client browser (such as
JavaScript, stylesheet files, and images) for your application.
In larger applications you may choose to divide these files into
a subdirectory hierarchy, but for smaller apps, it is generally
much simpler to maintain only a single directory for these files.
- *.htmlや*.jspなど - HTMLとJSPページに加えて、あなたの
アプリケーションにとって(JavaScriptやスタイルシートファイルのように)クライアントのブラウザから見えなければならないファイルです。
大きなアプリケーションでは、これらのファイルをサブディレクトリ階層に分ける
場合もありますが、小さいアプリケーションの場合にはこれらのファイルは同一の
ディレクトリにあるほうがより保守しやすいでしょう。
- /WEB-INF/web.xml - The Web Application Deployment
Descriptor for your application. This is an XML file describing
the servlets and other components that make up your application,
along with any initialization parameters and container-managed
security constraints that you want the server to enforce for you.
This file is discussed in more detail in the following subsection.
- WEB-INF/web.xml - あなたのアプリケーションの
Webアプリケーション配備指示子 (Web Application Deployment Descriptor)です。
これは、さまざまな初期化パラメタや、コンテナが管理しているセキュリティ上のあなたが設定したい制約に加えて、あなたのアプリケーションを構成するServletや他のコンポーネントについて記述しているXMLファイルです。
このファイルの詳細については、以下のサブセクションで述べます。
- /WEB-INF/classes/ - This directory contains any Java
class files (and associated resources) required for your application,
including both servlet and non-servlet classes, that are not combined
into JAR files. If your classes are organized into Java packages,
you must reflect this in the directory hierarchy under
/WEB-INF/classes/. For example, a Java class named
com.mycompany.mypackage.MyServlet
would need to be stored in a file named
/WEB-INF/classes/com/mycompany/mypackage/MyServlet.class.
- /WEB-INF/classes/ -
このディレクトリは、あなたのアプリケーションで必要な
Javaクラスファイル(と関連するリソース)が含まれ、
JARファイルにまとめられていないServletと非Servletクラスの両方が含まれています。
あなたのクラスが複数のJavaパッケージにわかれている場合には、
これをディレクトリ階層
WEB-INF/classes/の下に反映しなければなりません。
たとえば、
com.mycompany.mypackage.MyServlet という名前のJavaクラスは、
WEB-INF/classes/com/mycompany/mypackage/MyServlet.class
という名前のファイルとして格納する必要があります。
- /WEB-INF/lib/ - This directory contains JAR files that
contain Java class files (and associated resources) required for your
application, such as third party class libraries or JDBC drivers.
- /WEB-INF/lib/ -
このディレクトリには、
サードパーティのクラスライブラリやJDBCドライバのような、
あなたのアプリケーションで必要なJavaクラスファイル(と関連するリソースファイルを含んでいる)JARファイルが含まれています。
When you install an application into Tomcat (or any other
2.2/2.3-compatible server), the classes in the WEB-INF/classes/
directory, as well as all classes in JAR files found in the
WEB-INF/lib/ directory, are made visible to other classes
within your particular web application. Thus, if
you include all of the required library classes in one of these places (be
sure to check licenses for redistribution rights for any third party libraries
you utilize), you will simplify the installation of your web application --
no adjustment to the system class path (or installation of global library
files in your server) will be necessary.
Tomcat(または、他の2.2/2.3と互換性のあるサーバ)にアプリケーションをインストールするときには、
WEB-INF/lib/ディレクトリにあるJARファイルのすべての
クラスだけでなく、
WEB-INF/classes/ ディレクトリ内のクラスを
あなた自身のWebアプリケーションの内部から見えるようします。
つまり、必要なライブラリクラスのすべてを含んだものを、(もちろんあなたの利用するサードパーティライブラリの再配布権のライセンスを確認して)これらの場所のどこかにおけば、システムのクラスパスに変更を加える必要なしに、簡単にあなたのWebアプリケーションをインストールできます。
Much of this information was extracted from Chapter 9 of the Servlet
API Specification, version 2.3, which you should consult for more details.
この情報の大部分は、Servlet API仕様バージョン 2.3の9章から抜粋してるので
詳細は、そちらで調べてください。
|
| Webアプリケーション配備記述子 |
The description below uses the variable name $CATALINA_HOME
to refer to the directory into which you have installed Tomcat 4,
and is the base directory against which most relative paths are
resolved. However, if you have configured Tomcat 4 for multiple
instances by setting a CATALINA_BASE directory, you should use
$CATALINA_BASE instead of $CATALINA_HOME for each of these
references.
上記のように、環境変数名 $CATALINA_HOME を使用してあなたがインストールした
Tomcat 4 のディレクトリを参照し、そのディレクトリを基に関連するパスを解決します。
しかし、CATALINA_BASE ディレクトリを設定することで、Tomcat 4
を複数のインスタンスとして設定したい場合には、$CATALINA_HOMEの替わりに
$CATALINA_BASEを使用して、それぞれの参照をすべきです。
As mentioned above, the /WEB-INF/web.xml file contains the
Web Application Deployment Descriptor for your application. As the filename
extension implies, this file is an XML document, and defines everything about
your application that a server needs to know (except the context path,
which is assigned by the system administrator when the application is
deployed).
上記のように、WEB-INF/web.xmlファイルは、
あなたのアプリケーションのためのWebアプリケーション配備記述子を含んでいます。
ファイル名の拡張子が意味するように、このファイルはXMLドキュメントであり、(アプリケーションが配備されるときにシステム管理者が割り当てるコンテキストパスを除けば)サーバが必要とするあなたのアプリケーションについてのすべてを定義します。
The complete syntax and semantics for the deployment descriptor is defined
in Chapter 13 of the Servlet API Specification, version 2.3. Over time, it
is expected that development tools will be provided that create and edit the
deployment descriptor for you. In the meantime, to provide a starting point,
a basic web.xml file
is provided. This file includes comments that describe the purpose of each
included element.
完全な文法と配備識別子の意味は、Servlet API仕様バージョン2.3の13章で定義されています。
そのうち開発ツールがあなたに代わって配備識別子の作成と編集機能を提供するようになるでしょう。
しかし、当面の間は、出発点として基本的なweb.xml ファイルが提供されます。
このファイルは、含まれている要素のそれぞれの説明のためのコメントを含んでいます。
NOTE - The Servlet Specification includes a Document
Type Descriptor (DTD) for the web application deployment descriptor, and
Tomcat 4 enforces the rules defined here when processing your application's
/WEB-INF/web.xml file. In particular, you must
enter your descriptor elements (such as <filter>,
<servlet>, and <servlet-mapping> in
the order defined by the DTD (see Section 13.3).
注 - Servlet仕様は、Webアプリケーション配備記述子のための
ドキュメントタイプ記述子(DTD)を含んでおり、Tomcat 4は、
あなたのアプリケーションの/WEB-INF/web.xmlファイルを解析して
それに定義されたルールを実行します。特に、記述子の要素
(<filter>, <servlet>, <servlet-mapping> )は、DTDで定義された順番でなければなりません(13.3章参照)。
|
| Tomcat 4での配備 |
In order to be executed, a web application must be deployed on
a servlet container. This is true even during development.
We will describe using Tomcat 4 to provide the execution environment.
A web application can be deployed in Tomcat by one of three different
approaches:
Webアプリケーションを実行するためには、Servletコンテナに配備しなければなりません。
これは、開発期間中でも同じです。
実行環境を提供するために、Tomcat 4 を使って説明します。
Webアプリケーションは、以下の3つの異なる方法のどれかを使って、
Tomcatに配備することができます。
- Copy unpacked directory hierarchy into a subdirectory in directory
$CATALINA_HOME/webapps/. Tomcat will assign a
context path to your application based on the subdirectory name you
choose. We will use this technique in the build.xml
file that we construct, because it is the quickest and easiest approach
during development. Be sure to restart Tomcat after installing or
updating your application.
$CATALINA_HOME/webapps/ディレクトリ内のサブディレクトリに、
ディレクトリ構造を展開してコピーする。
Tomcatは、あなたの選んだサブディレクトリ名をベースにして、アプリケーションをコンテキストパスに割り当てます。
開発時にはこのテクニックがもっとも早く簡単なので、私たちは私たちが設定したbuild.xmlファイルで使用します。
- Copy the web application archive file into directory
$CATALINA_HOME/webapps/. When Tomcat is started, it will
automatically expand the web application archive file into its unpacked
form, and execute the application that way. This approach would typically
be used to install an additional application, provided by a third party
vendor or by your internal development staff, into an existing
Tomcat installation. NOTE - If you use this approach,
and wish to update your application later, you must both replace the
web application archive file AND delete the expanded
directory that Tomcat created, and then restart Tomcat, in order to reflect
your changes.
$CATALINA_HOME/webapps/ディレクトリにWebアプリケーションのアーカイブファイルをコピーする。
Tomcatが起動したときに、自動的にWebアプリケーションアーカイブファイルを
配備して、アプリケーションを実行します。
この方法は、一般的に、あなたの内部開発スタッフやサードパーティベンダーによって提供されるアプリケーションを、インストール済のTomcatに対して、追加インストールする場合に使用します。
注意 - この方法を使って、あとであなたのアプリケーションを
更新したくなった場合には、Webアプリケーションアーカイブファイルを入れ替えて、
さらにTomcatが作成した配備ディレクトリを削除して、
その変更を有効にするためにTomcatをリスタートする必要があります。
- Use the Tomcat 4 "Manager" web application to deploy and undeploy
web applications. Tomcat 4 includes a web application, deployed
by default on context path
/manager, that allows you to
deploy and undeploy applications on a running Tomcat server without
restarting it. See the administrator documentation (TODO: hyperlink)
for more information on using the Manager web application.
- Webアプリケーションの配備と撤収を行なうためのTomcat 4 の "Manager" Webアプリケーションを使用する。Tomcat 4 は、実行中のTomcatサーバをリスタート無しでアプリケーションの配備と撤収ができるようWebアプリケーションがデフォルトで
/manager
コンテキストパスに含まれています。
Manager Webアプリケーションを使用するための詳細情報は、管理者ドキュメント(TODO:ここにリンク)を参照してください。
- Add a
<Context> entry in the
$CATALINA_HOME/conf/server.xml configuration file.
This approach is described briefly below, and allows you to position
the document root of your web application at some point other than the
$CATALINA_HOME/webapps/ directory. You will need to restart
Tomcat to have changes in this configuration file take effect. See the
administrator documentation (TODO: hyperlink) for more information on
configuring new Contexts in this way.
$CATALINA_HOME/conf/server.xml設定ファイルに、<Context> エントリを追加する。
この方法は以下で簡単に説明しますが、
$CATALINA_HOME/webapps/ディレクトリ以外の場所に、
あなたのWebアプリケーションのドキュメントルートを設定することができます。
この設定ファイルの変更を反映させるには、Tomcatのリスタートが必要です。
この方法で新規にコンテキストを設定するための詳細情報は、管理者ドキュメント
(TODO: ここにリンク)を参照してください。
Deploying your app on other servlet containers will be specific to each
container, but all containers compatible with the Servlet API Specification
(version 2.2 or later) are required to accept a web application archive file.
Note that other containers are NOT required to accept an
unpacked directory structure (as Tomcat does), but this feature is commonly
available.
あなたのアプリケーションを他のサーブレットコンテナに配備する方法は、
それぞのコンテナによって違いますが、Servlet API仕様(バージョン2.2またはそれ以降)
に互換性のあるすべてのコンテナは、
Webアプリケーションアーカイブファイルを受け入れる必要があります。
注意: 他のコンテナは、(Tomcatがそうするように)展開(unpack)されたディレトクリ
校正の受け入れる必要はありません、がしかしこの機能は
たいてい有効です。
|
|