# Guide to OpenIG
Chapter 5. Configuring Deployment Containers

Sidebar | Prev | Up | Next

## 5.2. Jetty

Jetty reference links:

- Jetty Documentation

- Running Jetty on port 80

- Deploying Web Applications

Download and install Sun Java SE JDK 6 Update 21 or later. At this time these are the only versions of any JDK supported with OpenIG.

Download and install Jetty. The install directory is referred to as `$JETTY_HOME` from now on.

Configure Jetty to listen on the same port and protocol of the application you are protecting with OpenIG. If you are configuring OpenIG for the samples you do not have to modify the Jetty port configuration since the default for Jetty is 8080 and the samples use port 8080.

To configure Jetty to use a port other than 8080 you must modify the default `$JETTY_HOME/etc/jetty.xml`. The quickest way to do that is to search for the default value of 8080 and replace it with the new port number. The simplest way to get Jetty running on ports below 1024 is to run the Jetty process as root. This is only appropriate for sample purposes. Do not run Jetty as root in production.

If the application your are protecting is configured on an HTTPS port, you must configure Jetty for HTTPS as well.

If you are managing multiple applications in one domain you will need to turn on domain cookies in Jetty. This can be done by adding the following property to `$JETTY_HOME/contexts/root.xml` or to `$JETTY_HOME/etc/jetty.xml`. Note that any changes to `jetty.xml` impact all web applications running in the container.

    <Get name="sessionHandler">
        <Get name="sessionManager">
            <Set name="sessionDomain">example.com<Set>
        <Get>
    <Get>

If OpenIG accesses an SQL database you must configure Jetty for JNDI or use the Jetty Hightide distribution, which comes pre-configured for JNDI. Once you have Jetty configured you must add the jar for the database, and set up a JNDI data source and a reference to that data source in your web application. The following steps are for the MySQL Connector/J.

Download the MySQL JDBC Driver Connector/J Add it to the Jetty class path by copying it to `$JETTY_HOME/lib/jndi`.

Add a JNDI data source for your MySQL server and database in `$JETTY_HOME/etc/jetty.xml`.

    <New id="jdbc/forgerock" class="org.eclipse.jetty.plus.jndi.Resource">
      <Arg><Arg>
      <Arg>jdbc/forgerock<Arg>
      <Arg>
        <New class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
          <Set name="Url">jdbc:mysql://localhost:3306/databasename<Set>
          <Set name="User">mysqladmin<Set>
          <Set name="Password">11111111<Set>
        <New>
      <Arg>
    <New>

Add a resource reference to the data source in `$JETTY_HOME/etc/webdefault.xml`.

    <resource-ref>
        <description>My DataSource Reference<description>
        <res-ref-name>jdbc/forgerock<res-ref-name>
        <res-type>javax.sql.DataSource<res-type>
        <res-auth>Container<res-auth>
     <resource-ref>