03/19: Java > Apache Tomcat & Eclipse設定
Category: Web dev
Posted by: hajime osako
1. Download the following softwares
JAVA J2SE5 (JDK-1.5.x) [double click to install]
Apache-tomcat-5.5.x [double click to install. middle of the installation select J2SE directory which you just installed]
Eclipse lomboz-eclipse-emf-gef-jem-3.1 [archive and place it anywhere]
Eclipse Tomcat plug-in [archive and put it into Eclipse folder]
JDBC driver (JTDS or Microsoft) [Copy jtds driver (jtds-1.2.jar or newer) into Tomcat home\common\lib]
2. Setup Eclipse
Window -> Preferences -> Tomcat
Select version 5.x
Type or select Tomcat installed dir
Window -> Preferences -> Java -> Installed JREs
Select JDK (not JRE)
3. Modify Tomcat home\conf\server.xml (in Host tag)
<Context path="/my_project" reloadable="true"
docBase="%your project absolute path%"
workDir="%your project absolute path%\work">
<Resource name="jdbc/my_project_db" auth="Container" type="javax.sql.DataSource"
username="%db user%" password="%db pwd%"
driverClassName="net.sourceforge.jtds.jdbc.Driver"
url="jdbc:jtds:sqlserver://%database server address%:1433/%db name%" />
</Context>
Note: Tomcatプロジェクトをインポートするときは、先にプロジェクトを作っておく
古いApacheでのTomcatとの連携
1. Download mod_jk-apache-2.0.55.so from http://tomcat.apache.org/connectors-doc/howto/apache.html
The JK 2 connector is now deprecated. Use JK or mod_proxy_ajp instead.
2. rename to mod_jk.so and put under /modules
3. modify httpd.conf
# Load mod_jk module
LoadModule jk_module modules/mod_jk.so
# Declare the module for (remove this line on Apache 2.0.x)
#AddModule mod_jk.c
# Where to find workers.properties
JkWorkersFile conf/workers.properties
# Where to put jk logs
JkLogFile logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"
# Static files in the examples webapp are served by apache
Alias /EMS /Tomcat/webapps/EMS
# The following line prohibits users from directly access WEB-INF
AllowOverride None
deny from all
# All JSP will goes to worker1
JkMount /*.jsp worker1
# All servlets goes to worker1
JkMount /*/servlet/ worker1
4. create workers.properties (normal text file) into the folder which you specified in above
worker.list=worker1
# Definition for worker1
#
worker.worker1.port=8009
worker.worker1.host=localhost
worker.worker1.type=ajp13
5. restart apache and tomcat both.
JAVA J2SE5 (JDK-1.5.x) [double click to install]
Apache-tomcat-5.5.x [double click to install. middle of the installation select J2SE directory which you just installed]
Eclipse lomboz-eclipse-emf-gef-jem-3.1 [archive and place it anywhere]
Eclipse Tomcat plug-in [archive and put it into Eclipse folder]
JDBC driver (JTDS or Microsoft) [Copy jtds driver (jtds-1.2.jar or newer) into Tomcat home\common\lib]
2. Setup Eclipse
Window -> Preferences -> Tomcat
Select version 5.x
Type or select Tomcat installed dir
Window -> Preferences -> Java -> Installed JREs
Select JDK (not JRE)
3. Modify Tomcat home\conf\server.xml (in Host tag)
<Context path="/my_project" reloadable="true"
docBase="%your project absolute path%"
workDir="%your project absolute path%\work">
<Resource name="jdbc/my_project_db" auth="Container" type="javax.sql.DataSource"
username="%db user%" password="%db pwd%"
driverClassName="net.sourceforge.jtds.jdbc.Driver"
url="jdbc:jtds:sqlserver://%database server address%:1433/%db name%" />
</Context>
Note: Tomcatプロジェクトをインポートするときは、先にプロジェクトを作っておく
古いApacheでのTomcatとの連携
1. Download mod_jk-apache-2.0.55.so from http://tomcat.apache.org/connectors-doc/howto/apache.html
The JK 2 connector is now deprecated. Use JK or mod_proxy_ajp instead.
2. rename to mod_jk.so and put under /modules
3. modify httpd.conf
# Load mod_jk module
LoadModule jk_module modules/mod_jk.so
# Declare the module for
#AddModule mod_jk.c
# Where to find workers.properties
JkWorkersFile conf/workers.properties
# Where to put jk logs
JkLogFile logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"
# Static files in the examples webapp are served by apache
Alias /EMS /Tomcat/webapps/EMS
# The following line prohibits users from directly access WEB-INF
AllowOverride None
deny from all
# All JSP will goes to worker1
JkMount /*.jsp worker1
# All servlets goes to worker1
JkMount /*/servlet/ worker1
4. create workers.properties (normal text file) into the folder which you specified in above
worker.list=worker1
# Definition for worker1
#
worker.worker1.port=8009
worker.worker1.host=localhost
worker.worker1.type=ajp13
5. restart apache and tomcat both.