geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Geronimo v2.2 > Configuring Virtual Host in Jetty
Date Fri, 04 Sep 2009 06:22:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=GMOxDOC22&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
     <h2><a href="http://cwiki.apache.org/confluence/display/GMOxDOC22/Configuring+Virtual+Host+in+Jetty">Configuring
Virtual Host in Jetty</a></h2>
     <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~chirunhua@gmail.com">Runhua
Chi</a>
    </h4>
     Fix CSS problem by removing borderStyle option
          <div id="versionComment" class="noteMacro" style="display:none; padding: 5px;">
     Fix CSS problem by removing borderStyle option<br />
     </div>
          <br/>
     <div class="notificationGreySide">
         <p><a name="ConfiguringVirtualHostinJetty-top"></a></p>
<style type='text/css'>/*<![CDATA[*/
table.ScrollbarTable  {border: none;padding: 3px;width: 100%;padding: 3px;margin: 0px;background-color:
#f0f0f0}
table.ScrollbarTable td.ScrollbarPrevIcon {text-align: center;width: 16px;border: none;}
table.ScrollbarTable td.ScrollbarPrevName {text-align: left;border: none;}
table.ScrollbarTable td.ScrollbarParent {text-align: center;border: none;}
table.ScrollbarTable td.ScrollbarNextName {text-align: right;border: none;}
table.ScrollbarTable td.ScrollbarNextIcon {text-align: center;width: 16px;border: none;}

/*]]>*/</style><div class="Scrollbar"><table class='ScrollbarTable'><tr><td
width='33%' class='ScrollbarPrevName'>&nbsp;</td><td width='33%' class='ScrollbarParent'><sup><a
href="/confluence/display/GMOxDOC22/Configuring+virtual+host"><img border='0' align='middle'
src='/confluence/images/icons/up_16.gif' width='8' height='8'></a></sup><a
href="/confluence/display/GMOxDOC22/Configuring+virtual+host">Configuring virtual host</a></td><td
width='33%' class='ScrollbarNextName'>&nbsp;<a href="/confluence/display/GMOxDOC22/Configuring+Virtual+Host+in+Tomcat">Configuring
Virtual Host in Tomcat</a></td><td class='ScrollbarNextIcon'><a href="/confluence/display/GMOxDOC22/Configuring+Virtual+Host+in+Tomcat"><img
border='0' align='middle' src='/confluence/images/icons/forwd_16.gif' width='16' height='16'></a></td></tr></table></div>

<p>In the <a href="/confluence/display/GMOxDOC22/Configuring+Virtual+Host+in+Tomcat"
title="Configuring Virtual Host in Tomcat">Configuring Virtual Host in Tomcat</a>
section we describe how to define a Virtual Host in the Geronimo's <tt>config.xml</tt>
so applications can be deployed to specific hosts ( <em>Virtual Hosts</em>) with
a minimal configuration on the application deployment plans side. The need to define Virtual
Hosts at the server level ( <tt>config.xml</tt> ) only applies to Geronimo with
Tomcat distributions. </p>

<p>For the Jetty distribution of Apache Geronimo this configuration is dramatically
simpler. You just need to define the <b>&lt;virtual-host&gt;</b> tag in
the application's deployment plan and make sure that host name ( virtual host ) can be resolved
by the client. There is virtually no additional configuration needed on the Geronimo server
side.</p>

<p>In this example we continue to use the HelloWorld Web sample application covered
in the <a href="/confluence/display/GMOxDOC22/Quick+start+-+Apache+Geronimo+for+the+impatient"
title="Quick start - Apache Geronimo for the impatient">Quick start &#45; Apache Geronimo
for the impatient</a> section. Here is a summary of steps</p>


<ol>
	<li>Create a <tt>app_home</tt> directory somewhere in the file system,
from now on we will reference this location as <tt>&lt;app_home&gt;</tt>.</li>
	<li>Create a <tt>HelloWorld.jsp</tt> file in the <tt>&lt;app_home&gt;</tt>
directory and paste the following content.
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>HelloWorld.jsp</b></div><div
class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;html&gt;</span>
    <span class="code-tag">&lt;head&gt;</span>
        <span class="code-tag">&lt;jsp:useBean id=<span class="code-quote">"datetime"</span>
class=<span class="code-quote">"java.util.Date"</span>/&gt;</span>
        <span class="code-tag">&lt;title&gt;</span>Basic HelloWorld JSP<span
class="code-tag">&lt;/title&gt;</span>
    <span class="code-tag">&lt;/head&gt;</span>
    <span class="code-tag">&lt;body bgcolor=<span class="code-quote">"#909DB8"</span>&gt;</span>
        <span class="code-tag">&lt;h1&gt;</span><span class="code-tag">&lt;font
face=<span class="code-quote">"tahoma"</span> color=<span class="code-quote">"white"</span>&gt;</span>Hello
world from GERONIMO!<span class="code-tag">&lt;/font&gt;</span><span
class="code-tag">&lt;/h1&gt;</span>
        <span class="code-tag">&lt;font face=<span class="code-quote">"tahoma"</span>
color=<span class="code-quote">"white"</span>&gt;</span>on ${datetime}<span
class="code-tag">&lt;/font&gt;</span>
    <span class="code-tag">&lt;/body&gt;</span>
<span class="code-tag">&lt;/html&gt;</span>
</pre>
</div></div></li>
	<li>Create a <tt>WEB-INF</tt> directory under <tt>&lt;app_home&gt;</tt>.</li>
	<li>Create a <tt>web.xml</tt> file in the <tt>&lt;app_home&gt;\WEB-INF</tt>
directory and paste the following content.
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>web.xml</b></div><div class="codeContent
panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;?xml version=<span class="code-quote">"1.0"</span>
encoding=<span class="code-quote">"UTF-8"</span>?&gt;</span>
&lt;web-app version=<span class="code-quote">"2.4"</span>

   xmlns=<span class="code-quote">"http://java.sun.com/xml/ns/j2ee"</span>
   <span class="code-keyword">xmlns:xsi</span>=<span class="code-quote">"http://www.w3.org/2001/XMLSchema-instance"</span>
   xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"&gt;

    <span class="code-tag">&lt;welcome-file-list&gt;</span>
         <span class="code-tag">&lt;welcome-file&gt;</span>HelloWorld.jsp<span
class="code-tag">&lt;/welcome-file&gt;</span>
    <span class="code-tag">&lt;/welcome-file-list&gt;</span>

<span class="code-tag">&lt;/web-app&gt;</span>
</pre>
</div></div></li>
	<li>Create a <tt>geronimo-web.xml</tt> file in the <tt>&lt;app_home&gt;\WEB-INF</tt>
directory and paste the following content.
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>geronimo-web.xml</b></div><div
class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;?xml version=<span class="code-quote">"1.0"</span>
encoding=<span class="code-quote">"UTF-8"</span>?&gt;</span>
<span class="code-tag">&lt;web-app xmlns=<span class="code-quote">"http://geronimo.apache.org/xml/ns/j2ee/web-1.2"</span>&gt;</span>
        <span class="code-tag">&lt;environment&gt;</span>
                <span class="code-tag">&lt;moduleId&gt;</span>
                        <span class="code-tag">&lt;groupId&gt;</span>sample.applications<span
class="code-tag">&lt;/groupId&gt;</span>
                        <span class="code-tag">&lt;artifactId&gt;</span>HelloWorldApp<span
class="code-tag">&lt;/artifactId&gt;</span>
                        <span class="code-tag">&lt;version&gt;</span>2.1<span
class="code-tag">&lt;/version&gt;</span>
                        <span class="code-tag">&lt;type&gt;</span>war<span
class="code-tag">&lt;/type&gt;</span>
                <span class="code-tag">&lt;/moduleId&gt;</span>      
      
        <span class="code-tag">&lt;/environment&gt;</span>
        <span class="code-tag">&lt;context-root&gt;</span>/hello<span
class="code-tag">&lt;/context-root&gt;</span>
        
        <span class="code-tag"><span class="code-comment">&lt;!-- Add this
line to define a new Virtual Host in Geronimo - Jetty  --&gt;</span></span>
        <span class="code-tag">&lt;virtual-host&gt;</span>virtualhost1.com<span
class="code-tag">&lt;/virtual-host&gt;</span>
<span class="code-tag">&lt;/web-app&gt;</span>
</pre>
</div></div></li>
</ol>


<p>If you compare this deployment plan with the one described in the <a href="/confluence/display/GMOxDOC22/Quick+start+-+Apache+Geronimo+for+the+impatient"
title="Quick start - Apache Geronimo for the impatient">Quick start &#45; Apache Geronimo
for the impatient</a> section you will note that only one line has been added, that
is <tt>&lt;virtual-host&gt;virtualhost1.com&lt;/virtual-host&gt;</tt>.
This is all you need to define a virtual host in Geronimo with Jetty.</p>

<p>To deploy this application you can use the <b>--inPlace</b> option from
the deployer tool so you wont need to package the application nor copy it anywhere else. Just
run the following command:</p>

<p><b><tt>&lt;geronimo_home&gt;\bin\deploy --user system --password
manager deploy --inPlace &lt;app_home&gt;</tt></b></p>

<p><font color="white">
<div class="preformatted panel" style="background-color: #000000;border-style: solid;border-width:
1px;"><div class="preformattedContent panelContent" style="background-color: #000000;">
<pre>D:\geronimo-jetty6-jee5-2.1\bin&gt;deploy --user system --password manager
deploy --inPlace \HelloWorld_2.1
Using GERONIMO_BASE:   D:\geronimo-jetty6-jee5-2.1
Using GERONIMO_HOME:   D:\geronimo-jetty6-jee5-2.1
Using GERONIMO_TMPDIR: D:\geronimo-jetty6-jee5-2.1\var\temp
Using JRE_HOME:        C:\Java\jdk1.5.0_06\\jre
    Deployed sample.applications/HelloWorldApp/2.1/war @
    http://hcunico:8080/hello
</pre>
</div></div></font></p>


<p>Note that even when the successful deployment message on screen shows that the application
has been deployed to the <a href="http://XYZ:8080/hello" rel="nofollow">http://XYZ:8080/hello</a>
host, the application will only be accessible via the virtual host previously defined in the
<b>&lt;virtual-host&gt;</b> tag on the <tt>geronimo-web.xml</tt>
deployment plan.</p>
     </div>
     <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="http://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>

       <a href="http://cwiki.apache.org/confluence/display/GMOxDOC22/Configuring+Virtual+Host+in+Jetty">View
Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=93287&revisedVersion=9&originalVersion=8">View
Change</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/GMOxDOC22/Configuring+Virtual+Host+in+Jetty?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message