Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

Warning

All instructions are for Tomcat 7.0.29.  Please check with your team leader and verify which version of Tomcat you should download and install.

Quick

Links

to:

{

Panel
Wiki Markup
Table of Contents
:
minLevel
=
3
|
maxLevel
=
3
}
Panel

Download and Install Tomcat 7

If you encounter any broken links, go to the Apache Tomcat web site and select the Tomcat version from the DOWNLOAD section.

  1. Go to the Apache Tomcat download site.  Scroll down until you reach the 7.0.29 section.  Under Binary Distributions Core:, select the format for your OS and save the downloaded file to your workstation.  If you cannot find version 7.0.29, then follow the directions For older versions of Tomcat below and search of version 7.0.29.
    Note

    For older versions of Tomcat
    If you are looking for an archieve version of Tomcat, go to the Apache Apache Tomcat download site.  Scroll down until you reach the Quick Navigation section and click on Archives.  Select the version of Tomcat that you want, then click on bin and select the Tomcat format for your OS and save the downloaded file to your workstation.

  2. Unzip/untar the binaries to a new folder (e.g. /tomcat/7.0.9).
  3. Create an environment variable CATALINA_HOME which contains the path to your Tomcat installation.  For example: CATALINA_HOME=/tomcat/7.0.29/

Download and Install Tomcat 7 is now complete

unmigrated-wiki-markup
Panel
h3. *

Configure

Tomcat

7

* # *

  1. Configure
  1. tomcat-users.xml
*

  1. Open
  1. $
\
  1. {CATALINA_HOME}/conf/tomcat-users.xml
  1. with
  1. a
  1. text
  1. editor.
  Create the following 2 uses: {code}
  1.   Create the following 2 uses:
    Code Block
    
    <role rolename="manager-script"/>
    <role rolename="manager-gui"/>
    <user username="script" password="XXXXXXXX" roles="manager-script"/>
    <user username="gui" password="YYYYYYYY" roles="manager-gui"/>
    
{code} *•* The *script* user will be used to deploy your application to the Tomcat server. *•* The *gui* user will be used to access the Tomcat Manager. \\ {color:red}Be sure to change the passwords to passwords of your choice.{color} When you are satisified that everything is correct, save your changes. # *Install the
  1. The script user will be used to deploy your application to the Tomcat server.
    The gui user will be used to access the Tomcat Manager.
    Be sure to change the passwords to passwords of your choice.
    When you are satisified that everything is correct, save your changes.
  2. Install the ojdbc6-11.2.0.3.jar
*

  1. Install
  1. the
  1. ojdbc6-11.2.0.3.jar
  1. in
  1. either
  1. the
  1. $
\
  1. {CATALINA_HOME}/lib
  1. or
  1. the
  1. $
\
  1. {CATALINA_HOME}/common/lib
  1. directory.
&nbsp;&nbsp;The
  1.   The ojdbc6-11.2.0.3.jar
  1. has
  1. to
  1. go
  1. into
  1. only
  1. one
  1. directory.
&nbsp;&nbsp; \\ \\ If you do not have the
  1.   

    If you do not have the ojdbc6-11.2.0.3.jar,
  1. you
  1. can
[
  1. download
  1. the
  1. ojdbc6-11.2.0.3.jar
| ^ojdbc6-11.2.0.3.jar]
  1. now
  1. and
  1. save
  1. it
  1. to
  1. your
  1. workstation.
{anchor:Configure

  1. Anchor
    Configure context.xml
    Configure context.xml
} # *
  1. Configure
  1. context.xml
*

  1. Open
  1. $
\
  1. {CATALINA_HOME}/conf/context.xml
  1. with
  1. a
  1. text
  1. editor.
&nbsp;&nbsp; ## For
  1.   
    1. For non-Windows
    1. systems,
    1. change
    1. the
    1. <context>
    1. tag
    1. to
    1. the
    1. following:
{
    1. Code Block
}
    1. 
      <Context crossContext="true" useHttpOnly="false">
      
{code}
    1. For
    1. Windows
    1. systems,
    1. change
    1. the
    1. <context>
    1. tag
    1. to
    1. the
    1. following"
{
    1. Code Block
}
    1. 
      <Context antiResourceLocking="true" crossContext="true" useHttpOnly="false">
      
{code} {note} By setting *antiResourceLocking* to true, Tomcat will prevent any file locking. This will significantly impact startup time of applications, but allows full webapp hot deploy and undeploy on platforms or configurations where file locking can occur. If not specified, the default value is false. \\ \\ Please note that setting this to true has some side effects, including the disabling of JSP reloading in a running server: see Bugzilla 37668. \\ \\ Please note that setting this flag to true in applications that are outside the appBase for the Host (the webapps directory by default) will cause the application to be deleted on Tomcat shutdown. You probably don't want to do this, so think twice before setting antiResourceLocking=true on a webapp that's outside the appBase for its Host. {note} {note} By default, *Tomcat 7 sets HttpOnly to false on all session cookies*.&nbsp;&nbsp;This prevents any client side script from accessing the session ID. DWR uses the session cookie (and the session ID) to protect against cross site scripting attacks.&nbsp;&nbsp;With HTTPOnly set to false, DWR will start popping up “CSRF Security Error” dialogs. To prevent DWR from popping up “CSRF Security Error” dialogs, *useHttpOnly* must be set to *true*. {note} {anchor:add a resource definition} ## Add the following Resource Definition anywhere between the <context> and </context> tags: {code}
    1. Note

      By setting antiResourceLocking to true, Tomcat will prevent any file locking. This will significantly impact startup time of applications, but allows full webapp hot deploy and undeploy on platforms or configurations where file locking can occur. If not specified, the default value is false.

      Please note that setting this to true has some side effects, including the disabling of JSP reloading in a running server: see Bugzilla 37668.

      Please note that setting this flag to true in applications that are outside the appBase for the Host (the webapps directory by default) will cause the application to be deleted on Tomcat shutdown. You probably don't want to do this, so think twice before setting antiResourceLocking=true on a webapp that's outside the appBase for its Host.

      Note

      By default, Tomcat 7 sets HttpOnly to false on all session cookies.  This prevents any client side script from accessing the session ID.
      DWR uses the session cookie (and the session ID) to protect against cross site scripting attacks.  With HTTPOnly set to false, DWR will start popping up “CSRF Security Error” dialogs.
      To prevent DWR from popping up “CSRF Security Error” dialogs, useHttpOnly must be set to true.

      Anchor
      add a resource definition
      add a resource definition
    2. Add the following Resource Definition anywhere between the <context> and </context> tags:
      Code Block
      
      <Resource name="jdbc/MitsisDS"
         auth="Container"
         type="javax.sql.DataSource"
         driverClassName="oracle.jdbc.OracleDriver"
         url="jdbc:oracle:thin:@//earth-vault-2.mit.edu:1523/sundev11"
         username="XXXXXXXX"
         password="YYYYYYYY"
         maxActive="20"
         maxIdle="10"
         maxWait="-1"
         removeAbandoned="true"
         removeAbandonedTimeout="60"
         logAbandoned="true" />
      
      <ResourceLink global="jdbc/MitsisDS" name="jdbc/MitsisDS" type="javax.sql.DataSource"/>
      
{code} {color:red}If your
    1. If your project's
    1. JNDI
    1. name
    1. is
    1. something
    1. other
    1. than
*
    1. MitsisDS
*
    1. ,
    1. then
    1. you
    1. must
    1. change
*
    1. MitsisDS
*
    1. in
    1. the
    1. above
    1. to
    1. your
    1. project's
    1. JNDI
    1. name.
&nbsp;&nbsp;If you
    1.   If you don't
    1. know
    1. what
    1. JNDI
    1. name
    1. to
    1. use,
    1. your
    1. team
    1. leader
    1. can
    1. get
    1. it
    1. for
    1. you.
{color} {color:red}Be sure to change the *username* and *password*.{color} {note} You can have more than 1 Resource Definition in your context.xml.&nbsp;&nbsp;The only restriction is that each Resource Definition must have a unique *name*.&nbsp;&nbsp;Also, for each new Resource Definition, you should also add a corresponding ResourceLink.&nbsp;&nbsp;[At the bottom of this page| #context.mxl example] is an example of a context that contains multiple Resource Definitions. {note} \\ When you are satisified that everything is correct, save the changes. # *Configure setenv.bat* (setenv.bat is for Windows system.) {color:red}For non-Windows systems use setenv.sh and convert the code below using the appropriate replacement for *set*.{color} ## Open $\

    1. Be sure to change the username and password.
      Note

      You can have more than 1 Resource Definition in your context.xml.  The only restriction is that each Resource Definition must have a unique name.  Also, for each new Resource Definition, you should also add a corresponding ResourceLink.  At the bottom of this page is an example of a context that contains multiple Resource Definitions.


      When you are satisified that everything is correct, save the changes.
  1. Configure setenv.bat (setenv.bat is for Windows system.)
    For non-Windows systems use setenv.sh and convert the code below using the appropriate replacement for set.
    1. Open ${CATALINA_HOME}/bin/setenv.bat
    1. with
    1. a
    1. text
    1. editor.
&nbsp;&nbsp;If the
    1.   If the setenv.bat
    1. file
    1. does
    1. not
    1. exist,
    1. create
    1. it.
##
    1. Add
    1. the
    1. following
    1. to
    1. setenv.bat:
{
    1. Code Block
}
    1. 
      set JAVA_HOME=/path/to/Java/jdk1.6.0_27
      set PATH=%PATH%;/path/to/maven/apache-maven-2.2.1/bin
      set MAVEN_OPTS=-Djavax.net.ssl.trustStore=/path/to/keystores/serverTrustStore.jks -Djavax.net.ssl.trustStorePassword=changeit
      set CATALINA_OPTS=-Djavax.net.ssl.trustStorePassword=changeit -Djavax.net.ssl.keyStorePassword=changeit -Djavax.net.ssl.trustStore=/path/to/keystores/serverTrustStore.jks -Djavax.net.ssl.keyStore=/path/to/keystores/registrar.jks -Dlogs.dir=${user.home}
      set JAVA_OPTS=-server -Xmx1024m -Xms1024m -XX:MaxPermSize=1024m
      echo MAVEN_OPTS=%MAVEN_OPTS%
      echo CATALINA_OPTS=%CATALINA_OPTS%
      echo JAVA_OPTS=%JAVA_OPTS%
      
{code}
    1. Be
    1. sure
    1. to
    1. change
    1. the
    1. following:
##* *
      • /path/to/Java
*
      • -
      • the
      • path
      • to
      • your
      • Java
      • JDK
      • installation.
##* *
      • /path/to/maven
*
      • -
      • the
      • path
      • to
      • your
      • maven
      • installation.
##* *
      • /path/to/keystores
*
      • -
      • the
      • path
      • to
      • your
      • truststore
      • JKS
      • and/or
      • keystore
      • JKS.
# *
  1. Test
  1. the
  1. Tomcat
  1. installation
* ##
    1. Open
    1. a
    1. cmd
    1. window,
    1. cd
    1. to
    1. $
\
    1. {CATALINA_HOME}/bin
    1. and
    1. start
    1. the
    1. tomcat
    1. server.
##
    1. Open
    1. a
    1. browse
    1. and
    1. go
    1. to
    1. the
    1. URL:
    1. http://localhost:8080/manager/html.
##
    1. When
    1. prompted
    1. for
    1. the
    1. username
    1. and
    1. password,
    1. use
*
    1. gui
*
    1. for
    1. the
    1. user
    1. name
    1. and
    1. enter
    1. the
    1. password
    1. that
    1. you
    1. choose
    1. in
    1. Step
    1. 1
    1. above.

    1. If
    1. everything
    1. was
    1. done
    1. correctly,
    1. you
    1. will
    1. have
    1. the
    1. following
    1. page
    1. displayed:
!tomcatManager002.jpg! h4. {color:green}Configure Tomcat 7 is now complete{color}

    1. Image Added

Configure Tomcat 7 is now complete

Panel

Anchor
context.mxl example
context.mxl example

Example of a context which contains multiple Resource Definitions

Note

In the example below, the first two Resouce Definitions are identical except for the name property.  
The third Resource Definition differs not only in the name property but also differs in the type property and has an additional factory property.

In general, you can have as many Resource Definitions as you need just as long as each individual Resource Definition has a unique name property.

Code Block
Panel
Wiki Markup

{anchor:context.mxl example}
h3. *Example of a context which contains multiple Resource Definitions*
{note}
In the example below, the first two *Resouce Definitions* are identical except for the *name* property.&nbsp;&nbsp;
The third *Resource Definition* differs not only in the *name* property but also differs in the *type* property and has an additional *factory* property.
\\
\\
In general, you can have as many Resource Definitions as you need just as long as each individual Resource Definition has a *unique name property*.
{note}
{code}
<Context antiResourceLocking="true" crossContext="true" useHttpOnly="false">

    <WatchedResource>WEB-INF/web.xml</WatchedResource>

    <Resource name="jdbc/MitsisDs"
        auth="Container"
        type="javax.sql.DataSource"
        driverClassName="oracle.jdbc.OracleDriver"
        url="jdbc:oracle:thin:@//earth-vault-2.mit.edu:1523/sundev2"
        username="mydbusername"
        password="mydbpassword"
        maxActive="20"
        maxIdle="10"
        maxWait="-1"
        removeAbandoned="true"
        removeAbandonedTimeout="60"
        logAbandoned="true" />

    <Resource name="jdbc/iap"
        auth="Container"
        type="javax.sql.DataSource"
        driverClassName="oracle.jdbc.OracleDriver"
        url="jdbc:oracle:thin:@//earth-vault-2.mit.edu:1523/sundev2"
        username="mydbusername"
        password="mydbpassword"
        maxActive="20"
        maxIdle="10"
        maxWait="-1"
        removeAbandoned="true"
        removeAbandonedTimeout="60"
        logAbandoned="true" />

    <Resource name="jdbc/ssb"
        auth="Container"
        type="oracle.jdbc.pool.OracleDataSource"
        driverClassName="oracle.jdbc.OracleDriver"
        factory="oracle.jdbc.pool.OracleDataSourceFactory"
        url="jdbc:oracle:thin:@//earth-vault-2.mit.edu:1523/sundev2"
        username="mydbusername"
        password="mydbpassword"
        maxActive="20"
        maxIdle="10"
        maxWait="-1"
        removeAbandoned="true"
        removeAbandonedTimeout="60"
        logAbandoned="true"/>

    <ResourceLink global="jdbc/MitsisDS" name="jdbc/MitsisDS" type="javax.sql.DataSource"/>
    <ResourceLink global="jdbc/iap" name="jdbc/iap" type="javax.sql.DataSource"/>
    <ResourceLink global="jdbc/ssb" name="jdbc/ssb" type="javax.sql.DataSource"/>

</context>
{code}