Added by Jeroen Reijn, last edited by Bartosz Oudekerk on Sep 23, 2008  (view change)

Labels:

jetty jetty Delete
configure configure Delete
config config Delete
host host Delete
bind bind Delete
ip ip Delete
repository repository Delete
cms cms Delete
Enter labels to add to this page:
Wait Image 
Looking for a label? Just start typing.

While using the binary distributions

There could be cases in which you want to change the build-in Jetty configuration. For instance to do some performance tuning or for binding Jetty to a specific IP address. You can do this by changing the inline Jetty configuration. In the following sections we will show you how to change the Jetty configuration.

CMS and Repository

Locate the components.xconf in the config directory of the binary distribution of the CMS or Repository.

In this file you will find a line that looks like:

 <jetty activation="inline" id="jetty"/>

This makes Jetty use the default configuration and port (50000 or 60000) from the wrapper.conf file in the bin. Now if you want to change something to the Jetty configuration you can create you're own configuration file and point to it like this:

<jetty id="jetty">
  <config file="/somepath/config/jetty.xml"/>
</jetty>

jetty.xml sample

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure 1.2//EN" "http://jetty.mortbay.org/configure_1_2.dtd">

<!-- =============================================================== -->
<!-- Configure the Jetty Server                                      -->
<!-- =============================================================== -->
<Configure class="org.mortbay.jetty.Server">

  <!-- =============================================================== -->
  <!-- Configure the Request Listeners                                 -->
  <!-- =============================================================== -->

  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <!-- Add and configure a HTTP listener to port 8888                  -->
  <!-- The default port can be changed using: java -Djetty.port=80     -->
  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <Call name="addListener">
    <Arg>
      <New class="org.mortbay.http.SocketListener">
        <Set name="Port"><SystemProperty name="jetty.port" default="60000"/></Set>
        <Set name="MinThreads">200</Set>
        <Set name="MaxThreads">500</Set>
        <Set name="MaxIdleTimeMs">30000</Set>
        <Set name="LowResourcePersistTimeMs">1000</Set>
        <Set name="ConfidentialPort">8443</Set>
        <Set name="IntegralPort">8443</Set>
        <Set name="PoolName">main</Set>
        <Set name="Host">127.0.0.1</Set>
      </New>
    </Arg>
  </Call>

  <!-- =============================================================== -->
  <!-- Configure the Request Log                                       -->
  <!-- =============================================================== -->
  <Set name="RequestLog">
    <New class="org.mortbay.http.NCSARequestLog">
      <Arg><SystemProperty name="jetty.home" default="."/>/logs/yyyy_mm_dd.request.log</Arg>
      <Set name="retainDays">90</Set>
      <Set name="append">true</Set>
      <Set name="extended">false</Set>
      <Set name="buffered">false</Set>
      <Set name="LogTimeZone">GMT</Set>
    </New>
  </Set>

  <!-- =============================================================== -->
  <!-- Configure the Other Server Options                              -->
  <!-- =============================================================== -->
  <Set name="requestsPerGC">2000</Set>
  <Set name="statsOn">false</Set>

</Configure>

If you want to use Apache/mod_proxy for loadbalancing, another section you might want to add nested with the configure tags is the following:

<Call name="addWebApplication">
  <!-- The context path spec. Which must be of the form / or /path/* -->
  <Arg>/</Arg>
  <!-- The Web application directory or WAR file. -->
  <Arg>
    <SystemProperty name="jetty.home" default="."/>/cocoon/
  </Arg>
  <!-- This will set the session manager worker name to "node1" -->
  <Call name="getWebApplicationHandler">
    <Call name="getSessionManager">
      <Set name="workerName" type="string">node1</Set>
    </Call>
  </Call>
</Call>

While building from source

The Repository

The repository allows you to configure the location of the Jetty configuration file from the build.properties or project.properties. By adding the next few lines to your build.properties file you can create a build that has a file reference to the a jetty configuration located somewhere else on the filesystem.

# ------------------------------------------------------------------------
# Jetty configuration file (relative path)
# ------------------------------------------------------------------------
# The 'maven.jetty.configpath' path is relative to the
# Fortress home directory (the directory containing 'bin', 'config', 'logs',
# etc.). If maven.jetty.useconfigpath is set to false the internal jetty
# config (on port 8888) is used.
maven.jetty.useconfigpath=true
maven.jetty.configpath=config/jetty.xml
maven.jetty.port=60000