title: How to deploy Jenkins in Jetty server correctly?
body: <p>After installing the jetty on ubuntu I deployed the jenkins as root on the jetty as follows:</p>
  
  <pre><code>/opt/jetty/webapps$ ls
  jenkins-1.622.war  jenkins.xml  spdy.war
  service jetty restart
  </code></pre>
  
  <p>I created the <a href="http://pietervogelaar.nl/ubuntu-12-04-install-jenkins-1-4-with-jetty-9" rel="nofollow">jenkins.xml</a> file:</p>
  
  <pre><code>nano /opt/jetty/webapps/jenkins.xml
  </code></pre>
  
  <p>I copied and pasted the following code:</p>
  
  <pre><code>&lt;?xml version="1.0"  encoding="ISO-8859-1"?&gt;
  &lt;!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd"&gt;
  
  &lt;!-- ==================================================================
  Configure and deploy the jenkins web application in $(jetty.home)/webapps/jenkins
  
  Note. If this file did not exist or used a context path other that /jenkins
  then the default configuration of jetty.xml would discover the jenkins
  webapplication with a WebAppDeployer.  By specifying a context in this
  directory, additional configuration may be specified and hot deployments
  detected.
  ===================================================================== --&gt;
  
  &lt;Configure class="org.eclipse.jetty.webapp.WebAppContext"&gt;
  
  
    &lt;!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --&gt;
    &lt;!-- Required minimal context configuration :                        --&gt;
    &lt;!--  + contextPath                                                  --&gt;
    &lt;!--  + war OR resourceBase                                          --&gt;
    &lt;!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --&gt;
    &lt;Set name="contextPath"&gt;/jenkins&lt;/Set&gt;
    &lt;Set name="war"&gt;&lt;SystemProperty name="jetty.home" default="."/&gt;/webapps/jenkins.war&lt;/Set&gt;
  
    &lt;!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --&gt;
    &lt;!-- Optional context configuration                                  --&gt;
    &lt;!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --&gt;
    &lt;Set name="extractWAR"&gt;true&lt;/Set&gt;
    &lt;Set name="copyWebDir"&gt;false&lt;/Set&gt;
    &lt;Set name="defaultsDescriptor"&gt;&lt;SystemProperty name="jetty.home" default="."/&gt;/etc/webdefault.xml&lt;/Set&gt;
    &lt;!--&lt;Set name="overrideDescriptor"&gt;&lt;SystemProperty name="jetty.home" default="."/&gt;/webapps/jenkins.d/override-web.xml&lt;/Set&gt;--&gt;
  
    &lt;Get name="securityHandler"&gt;
      &lt;Set name="loginService"&gt;
        &lt;New class="org.eclipse.jetty.security.HashLoginService"&gt;
          &lt;Set name="name"&gt;Jenkins Realm&lt;/Set&gt;
          &lt;Set name="config"&gt;&lt;SystemProperty name="jetty.home" default="."/&gt;/etc/realm.properties&lt;/Set&gt;
              &lt;!-- To enable reload of realm when properties change, uncomment the following lines --&gt;
              &lt;!-- changing refreshInterval (in seconds) as desired                                --&gt;
              &lt;!--
             &lt;Set name="refreshInterval"&gt;5&lt;/Set&gt;
             &lt;Call name="start"&gt;&lt;/Call&gt;
             --&gt;
        &lt;/New&gt;
      &lt;/Set&gt;
      &lt;Set name="authenticator"&gt;
        &lt;New class="org.eclipse.jetty.security.authentication.FormAuthenticator"&gt;
          &lt;Set name="alwaysSaveUri"&gt;true&lt;/Set&gt;
        &lt;/New&gt;
      &lt;/Set&gt;
      &lt;Set name="checkWelcomeFiles"&gt;true&lt;/Set&gt;
    &lt;/Get&gt;
  
    &lt;!-- Add context specific logger
   &lt;Set name="handler"&gt;
     &lt;New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler"&gt;
       &lt;Set name="requestLog"&gt;
      &lt;New id="RequestLogImpl" class="org.eclipse.jetty.server.NCSARequestLog"&gt;
        &lt;Set name="filename"&gt;&lt;Property name="jetty.logs" default="./logs"/&gt;/jenkins-yyyy_mm_dd.request.log&lt;/Set&gt;
        &lt;Set name="filenameDateFormat"&gt;yyyy_MM_dd&lt;/Set&gt;
        &lt;Set name="append"&gt;true&lt;/Set&gt;
        &lt;Set name="LogTimeZone"&gt;GMT&lt;/Set&gt;
      &lt;/New&gt;
       &lt;/Set&gt;
     &lt;/New&gt;
   &lt;/Set&gt;
   --&gt;
  
  &lt;/Configure&gt;
  </code></pre>
  
  <p>Create the directory</p>
  
  <pre><code>mkdir -p /home/jetty/.jenkins
  chown -R jetty:jetty /home/jetty/
  </code></pre>
  
  <p>The jenkins.xml file refers to the file <a href="http://redutan.blogspot.com.br/2014/01/jetty9-jenkins-http-error-503-problem.html" rel="nofollow">/etc/realm.properties</a></p>
  
  <p>I created the /etc/realm.properties file and copied and pasted the following code:</p>
  
  <pre><code>#
  # This file defines users passwords and roles for a HashUserRealm
  #
  # The format is
  #  &lt;username&gt;: &lt;password&gt;[,&lt;rolename&gt; ...]
  #
  # Passwords may be clear text, obfuscated or checksummed.  The class
  # org.eclipse.util.Password should be used to generate obfuscated
  # passwords or password checksums
  #
  # If DIGEST Authentication is used, the password must be in a recoverable
  # format, either plain text or OBF:.
  #
  jetty: MD5:164c88b302622e17050af52c89945d44,user
  admin: CRYPT:adpexzg3FUZAk,server-administrator,content-administrator,admin,user
  other: OBF:1xmk1w261u9r1w1c1xmq,user
  plain: plain,user
  user: password,user
  
  # This entry is for digest auth.  The credential is a MD5 hash of username:realmname:password
  digest: MD5:6e120743ad67abfbc385bc2bb754e297,user
  </code></pre>
  
  <p>Then the following commands performed</p>
  
  <pre><code>cp /etc/realm.properties /opt/jetty/etc    
  chown -R jetty:jetty /opt/jetty/webapps
  chown -R jetty:jetty /opt/jetty/etc
  service jetty restart
  </code></pre>
  
  <p>I accessed the URL for the browser:
  <a href="http://myserver:8080/jenkins" rel="nofollow">http://myserver:8080/jenkins</a></p>
  
  <p>But displays the following message:</p>
  
  <pre><code>HTTP ERROR: 503
  
  Problem accessing /jenkins/. Reason:
  
      Service Unavailable
  
  Powered by Jetty://
  </code></pre>
  
  <p>I forgot to any permission? Why am I not able to access the jenkins? Where am I wrong?</p>