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 > JBoss to Geronimo - Servlets and JSPs Migration
Date Mon, 20 Jul 2009 03:07: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/JBoss+to+Geronimo+-+Servlets+and+JSPs+Migration">JBoss
to Geronimo - Servlets and JSPs Migration</a></h2>
     <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~sophia">Ying
Tang</a>
    </h4>
     
          <br/>
     <div class="notificationGreySide">
         <p><a name="JBosstoGeronimo-ServletsandJSPsMigration-top"></a><br/>
This article will help you migrate servlets and JSPs deployed JBoss v4 to Apache Geronimo.
This article is part of a series of migration articles covering different types of applications
migration.</p>

<p>This article covers the migration one of the most fundamental aspects of J2EE: servlets
and JSPs. The sample application used for this migration exercise is <a href="/confluence/download/attachments/93344/college_fest.zip?version=1">College
Fest</a> which just contains servlets and JSPs for handling the flow of control. The
College Fest sample application does not use any database, for details on migrating JDBC applications
refer to the <a href="/confluence/display/GMOxDOC22/JBoss+to+Geronimo+-+JDBC+Migration+%28Unverified+on+2.1%29"
title="JBoss to Geronimo - JDBC Migration (Unverified on 2.1)">JBoss to Geronimo &#45;
JDBC Migration &#40;Unverified on 2.1&#41;</a> article.</p>

<p>After reading this article you should be able to reconfigure the JBoss build files
and the deployment descriptors to set up the Apache Geronimo destination environment and then
deploying simple Web applications.</p>

<p>This article is organized in the following sections:</p>

<ul>
	<li><a href="#JBosstoGeronimo-ServletsandJSPsMigration-implementation">Servlets
and JSPs implementation analysis</a></li>
	<li><a href="#JBosstoGeronimo-ServletsandJSPsMigration-sampleApp">Sample application</a></li>
	<li><a href="#JBosstoGeronimo-ServletsandJSPsMigration-JBoss">The JBoss environment</a></li>
	<li><a href="#JBosstoGeronimo-ServletsandJSPsMigration-Geronimo">The Geronimo
environment</a></li>
	<li><a href="#JBosstoGeronimo-ServletsandJSPsMigration-migration">Step-by-step
migration</a></li>
	<li><a href="#JBosstoGeronimo-ServletsandJSPsMigration-summary">Summary</a></li>
</ul>


<h1><a name="JBosstoGeronimo-ServletsandJSPsMigration-ServletsandJSPsimplementationanalysis"></a>Servlets
and JSPs implementation analysis <a name="JBosstoGeronimo-ServletsandJSPsMigration-implementation"></a></h1>
<p>Servlets and JSPs implementations may vary from one application server to another.
The purpose of this section is to provide servlets and JSPs specific feature-to-feature comparison
between JBoss and Apache Geronimo so you can clearly identify the differences and plan accordingly
before migration.</p>

<p>Apache Geronimo includes a Web application container supporting J2EE Web applications.
The Web container itself supports basic configuration such as network ports and SSL options,
and each Web application may include Geronimo-specific configuration information as well.
Web applications participate in the Geronimo security infrastructure, so authenticating to
a Web application allows access to secure EJBs and Connectors as well.</p>

<p>Apache Geronimo currently supports two Web containers: <b>Jetty</b> and
<b>Tomcat</b>.</p>

<h3><a name="JBosstoGeronimo-ServletsandJSPsMigration-Jetty"></a>Jetty</h3>
<p>Jetty is a 100% Java HTTP Server and Servlet Container. This means that you do not
need to configure and run a separate Web server in order to use servlets and JSPs to generate
dynamic content. Jetty is a fully featured Web server for static and dynamic content.</p>

<p>Unlike separate server/container solutions, Jetty's Web server and Web application
run in the same process without interconnection overheads and complications.  Furthermore,
as a pure java component, Jetty can be easily included in your application for demonstration,
distribution or deployment. Jetty is available on all Java supported platforms.</p>

<p>In Geronimo, you need to explicitly configure the pathways used by browsers attempting
to connect to the Web container. In the case of Jetty, the default Web container, these pathways
are known as connectors. The standard configuration includes a Jetty connector supporting
HTTP on port 8080, as well as a HTTPS connector on port 8443.</p>

<p>Each Jetty connector is a GBean, so the process of configuring a Jetty connector
involves configuring a GBean.</p>

<h3><a name="JBosstoGeronimo-ServletsandJSPsMigration-ApacheTomcat"></a>Apache
Tomcat</h3>
<p>Apache Tomcat is the servlet container that is used in the official Reference Implementation
for the Java Servlet and JavaServer Pages technologies.</p>

<p><a href="http://java.sun.com/products/servlet" rel="nofollow">http://java.sun.com/products/servlet</a><br/>
<a href="http://java.sun.com/products/jsp" rel="nofollow">http://java.sun.com/products/jsp</a></p>

<h2><a name="JBosstoGeronimo-ServletsandJSPsMigration-Thedifferences"></a>The
differences</h2>
<p>JBoss v4 supports only Tomcat 5.5, which is the default Web container. The embedded
Tomcat service is the expanded SAR <b>jbossweb-tomcat55.sar</b> in the deploy
directory. The <tt>web.xml</tt> file that provides a default configuration set
for Web application is also found in this exapanded SAR directory structure. </p>

<p>The HTTP connector is set up on port 8080 and port 8009 is used if you want to connect
via a separate Web server such as Apache HTTP.</p>

<p>In addition to the default Web container, the second major difference lies in the
deployment plan. A deployment plan in Geronimo is similar to a J2EE deployment descriptor
in the sense that it is an XML file that contains the configuration information for a specific
application module or service.</p>

<p>For very simple Web applications with no security nor resource references, a Geronimo
deployment plan is not required, a default context root and dependencies will be provided
automatically at deployment time.</p>

<p>The Geronimo Web application deployment plan is <b>geronimo-web.xml</b>.
The corresponding deployment descriptor in Jboss is <tt>jboss-web.xml</tt>. For
further details on Geronimo deployment architecture you may refer to the <a href="http://www.ibm.com/developerworks/library/os-ag-deploy"
rel="nofollow">Understand Geronimo's deployment architecture</a>.</p>

<p>Another difference with servlets and JSPs lies in the way the Web application is
deployed. In Geronimo, the application package (ear, war, rar or jar) is deployed using the
deployment tool <tt>deployer.jar</tt> located in the <tt>&lt;geronimo_home&gt;/bin</tt>
directory.<br/>
<a name="JBosstoGeronimo-ServletsandJSPsMigration-deploymentTool"></a><br/>
The <tt>deployer.jar</tt> deploys the application module based on the information
provided in the deployment plan (if a plan is provided) to the Geronimo server. The server
then saves the metadata to a configuration store and the executables to a binary repository.
The following figure illustrates the behavior of the deployment tool.</p>

<p><img src="/confluence/download/attachments/93344/deployer.jpg" align="absmiddle"
border="0" /></p>

<p>In JBoss, a Web application is deployed by simply copying the application package
(ear, war, rar or jar) into the <tt>&lt;jboss_home&gt;/server/&lt;your_server_name&gt;/deploy</tt>
directory from where the server detects its presence and deploys it accordingly.</p>

<p>The following table summarizes the differences between JBoss and Geronimo.</p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>Feature</th>
<th class='confluenceTh'>JBoss v4</th>
<th class='confluenceTh'>Apache Geronimo</th>
</tr>
<tr>
<td class='confluenceTd'>Deployment descriptor/plan</td>
<td class='confluenceTd'>jboss.xml</td>
<td class='confluenceTd'>geronimo-web.xml</td>
</tr>
<tr>
<td class='confluenceTd'>Method of deployment</td>
<td class='confluenceTd'>Copy the package (ear, war, rar or jar) to the deploy folder
of the JBoss server <tt>&lt;jboss_home&gt;/server/&lt;your_server_name&gt;/deploy</tt></td>
<td class='confluenceTd'><a href="/confluence/display/GMOxDOC22/Tools+and+commands#Toolsandcommands-Deployertool">Deployer
tool</a> available in server's bin directory<br/>
<tt>&lt;geronimo_home&gt;/bin</tt>. Deployment is also available through
the <a href="/confluence/display/GMOxDOC22/Deploying+and+undeploying+applications#Deployingandundeployingapplications-ViaGeronimoAdministrationConsole">administration
console</a>. A third option is <a href="/confluence/display/GMOxDOC22/Deploying+and+undeploying+applications#Deployingandundeployingapplications-Viahotdeployment">Hot
Deployment</a>, which would be the equivalent to JBoss functionality.</td>
</tr>
<tr>
<td class='confluenceTd'>Web container</td>
<td class='confluenceTd'>Apache Tomcat 5.5</td>
<td class='confluenceTd'>Jetty and/or Apache Tomcat</td>
</tr>
</tbody></table>

<p><a href="#JBosstoGeronimo-ServletsandJSPsMigration-top">Back to Top</a></p>

<h1><a name="JBosstoGeronimo-ServletsandJSPsMigration-Sampleapplication"></a>Sample
application <a name="JBosstoGeronimo-ServletsandJSPsMigration-sampleApp"></a></h1>
<p>The <a href="/confluence/download/attachments/93344/college_fest.zip?version=1">College
Fest</a> application handles registration for events at a college festival. This is
a very simple application that does not use any type of database. The College Fest application
has the following four pages:</p>

<ul>
	<li>Welcome page</li>
	<li>Event List page</li>
	<li>Event Details page</li>
	<li>Registration page</li>
</ul>


<p>The following figure illustrates the application flow:</p>

<p><img src="/confluence/download/attachments/93344/webApp_flow.jpg" align="absmiddle"
border="0" /></p>

<p>The user access the Welcome page and enters user name and college. From there the
user can see the list of available events. The user can access the details for each Event
by clicking them from the list. From the Event details page the user can register for that
particular event. </p>

<h2><a name="JBosstoGeronimo-ServletsandJSPsMigration-ApplicationclassesandJSPpages"></a>Application
classes and JSP pages</h2>
<p>The College Fest sample application consists of the following two servlets:</p>
<ul>
	<li>WelcomeServlet - Handles user login and then grabs the user name and dispatches
this to the next servlet.</li>
	<li>PersonalServlet - Personalizes the page for the user and hands over control to
welcome.jsp.</li>
</ul>


<p>The College Fest sample application also includes the following JSP pages:</p>
<ul>
	<li>welcome.jsp - Displays the events list to the user so that s/he can choose on what
event to register.</li>
	<li>dc.jsp - Displays the details for the Dumb Charades event.</li>
	<li>pp.jsp - Displays the details for the Pot Potpourri event.</li>
	<li>wtgw.jsp - Displays the details for the  What's The Good Word event.</li>
	<li>gq.jsp - Displays the details for the General Quiz event.</li>
	<li>team_reg.jsp - Handles the user registration for one event.</li>
</ul>


<h2><a name="JBosstoGeronimo-ServletsandJSPsMigration-Toolsused"></a>Tools
used</h2>
<p>The tools used for developing and building the College Fest sample application are:</p>

<h3><a name="JBosstoGeronimo-ServletsandJSPsMigration-Eclipse"></a>Eclipse</h3>
<p>The Eclipse IDE was used for development of the sample application. This is a very
powerful and popular open source development tool. Integration plug-ins are available for
both JBoss and Geronimo. Eclipse can be downloaded from the following URL:<br/>
<a href="http://www.eclipse.org" rel="nofollow">http://www.eclipse.org</a></p>

<h3><a name="JBosstoGeronimo-ServletsandJSPsMigration-ApacheAnt"></a>Apache
Ant</h3>
<p>Ant is a pure Java build tool. It is used for building the war files for the College
Fest application. Ant can be downloaded from the following URL:<br/>
<a href="http://ant.apache.org" rel="nofollow">http://ant.apache.org</a></p>

<p><a href="#JBosstoGeronimo-ServletsandJSPsMigration-top">Back to Top</a></p>

<h1><a name="JBosstoGeronimo-ServletsandJSPsMigration-TheJBossenvironment"></a>The
JBoss environment <a name="JBosstoGeronimo-ServletsandJSPsMigration-JBoss"></a></h1>
<p>This section shows you how and where the sample JBoss reference environment was installed
so you can map this scenario to your own implementation.</p>

<p>Detailed instructions for installing, configuring, and managing JBoss are provided
in the product documentation. Check the <a href="http://www.jboss.org/jbossas/docs/" rel="nofollow">product
Web site</a> for the most updated documents.</p>

<p>The following list highlights the general tasks you will need to complete to install
and configure the initial environment as the starting point for deploying the sample application.</p>

<ol>
	<li>Download and install JBoss v4 as explained in the product documentation guides.
From now on the installation directory will be referred as <tt>&lt;jboss_home&gt;</tt>.</li>
	<li>Create a copy of the default JBoss v4 application server. Copy recursively <tt>&lt;jboss_home&gt;\server\default</tt>
to <tt>&lt;jboss_home&gt;\server\&lt;your_server_name&gt;</tt>.</li>
	<li>Start the new server by running the <tt>run.sh -c &lt;your_server_name&gt;</tt>
command from the <tt>&lt;jboss_home&gt;\bin</tt> directory.</li>
	<li>Once the server is started, you can verify that it is running by opening a Web
browser and pointing it to this URL: <a href="http://localhost:8080" rel="nofollow">http://localhost:8080</a>.
You should see the JBoss Welcome window and be able to access the JBoss console.</li>
	<li>Once the application server is up and running, the next step is to install and
configure all the remaining prerequisite software required by the sample application. This
step is described in the following section.</li>
</ol>


<p>As mentioned before, Apache Ant is used to build the binaries for the College Fest
application. If you do not have Ant installed this is a good time for doing it and make sure
that <b>&lt;ant_home&gt;\bin</b> directory is added to the system's path
variable.</p>

<p>Apache Ant can be downloaded from the following URL:</p>

<p><a href="http://ant.apache.org" rel="nofollow">http://ant.apache.org</a></p>

<h2><a name="JBosstoGeronimo-ServletsandJSPsMigration-Buildthesampleapplication"></a>Build
the sample application</h2>
<p>The College Fest application included with this article provides an Ant script that
you will use in order to build the application. Download the College Fest application from
the following link:</p>

<p><a href="/confluence/download/attachments/93344/college_fest.zip?version=1">College
Fest</a></p>

<p>After extracting the zip file, a college_fest directory is created. In that directory
open the <b>build.properties</b> file and edit the properties to match your environment
as shown in the following example:</p>

<div class="preformatted panel" style="border-style: solid;border-width: 1px;"><div
class="preformattedHeader panelHeader" style="border-bottom-width: 1px;border-bottom-style:
solid;"><b>Update the build.properties file</b></div><div class="preformattedContent
panelContent">
<pre>#Replace java.home with your jdk directory
java.home=&lt;JAVA_HOME&gt;
#Replace j2ee.home with the parent directory of lib/j2ee.jar
j2ee.home=&lt;jboss_home&gt;/server/&lt;your_server_name&gt;
#Replace with jboss home directory
jboss.server=&lt;jboss_home&gt;/server/&lt;your_server_name&gt;
#geronimo home directory
geronimo.home=&lt;geronimo_home&gt;
</pre>
</div></div>

<p>In the college_fest directory you can also find two build files, build.xml and jboss-build.xml.
build.xml is the default build file so if you just type <b>ant</b>  this file
will be used for building the application. For this particular sample application the jboss-build.xml
file is provided.</p>

<p>From a command line, still within the college_fest directory type the following command:</p>

<p><b><tt>ant -f jboss-build.xml clean deploy</tt></b></p>

<p>With this command, ant will use the targets defined in the jboss-build.xml file to
build the College Fest application and deploy it to the JBoss server. Take a special look
at <b>&lt;target name="deploy" ...&gt;</b>, here is where the <tt>jboss-build.xml</tt>
tell ant where to deploy the WAR file. The following example shows the definitions in the
<tt>jboss-build.xml</tt> file.</p>

<style type="text/css">
@import url(/confluence/download/resources/confluence.ext.code:code/shStyles.css);
</style>
<!--[if IE]>
<style type="text/css">
    .code textarea, .code input { padding: 0 !important; }
</style>
<![endif]-->
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shCore.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushCSharp.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushPhp.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushJScript.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushVb.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushSql.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushXml.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushShell.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushDelphi.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushPython.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushJava.js"></script>
<div class="code">
<textarea name="newcodemacro" class="xml:nocontrols:nogutter" rows="10" readonly="readonly">&lt;?xml
version="1.0"?&gt;
&lt;!-- build file for building a war --&gt;

&lt;project name="build" default="war" basedir="."&gt;

    &lt;property file="build.properties"/&gt;
    &lt;property name="src.dir" value="src"/&gt;
    &lt;property name="dest.dir" value="bin"/&gt;
    
    &lt;target name="clean" description="Delete all generated files"&gt;
        &lt;echo message="Deleting bin directory" /&gt;
        &lt;delete dir="bin" /&gt;
    &lt;/target&gt;

	&lt;target name="compile"&gt;
		&lt;mkdir dir="${dest.dir}"/&gt;
		&lt;javac srcdir="${src.dir}" destdir="${dest.dir}"&gt;
			&lt;classpath path="${java.home}/lib/tools.jar"/&gt;
			&lt;classpath path="${j2ee.home}/lib/j2ee.jar"/&gt;
		&lt;/javac&gt;
	&lt;/target&gt;

	&lt;target name="war" depends="compile"&gt;
		&lt;war destfile="college_fest.war" webxml="WEB-INF/web.xml"&gt;
			&lt;zipfileset dir="jsp" prefix="jsp"/&gt;   	 
			&lt;zipfileset dir="pix" prefix="pix"/&gt;   	 
			&lt;classes dir="${dest.dir}"/&gt;   
                        &lt;webinf dir="WEB-INF" /&gt;
		&lt;/war&gt;
	&lt;/target&gt;

	&lt;target name="deploy" depends="war"&gt;
		&lt;copy file="college_fest.war" todir="${jboss.server}/deploy"/&gt;
	&lt;/target&gt;

	&lt;target name="undeploy"&gt;
		&lt;delete file="${jboss.server}/deploy/college_fest.war"/&gt;
    &lt;/target&gt;
&lt;/project&gt;</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>


<p>The war created by the ant build contains a JBoss specific deployment descriptor,
the <tt>jboss-web.xml</tt> file in the <tt>WEB-INF</tt> directory
of the WAR is shown in the following example.</p>

<div class="code">
<textarea name="newcodemacro" class="xml:nocontrols:nogutter" rows="10" readonly="readonly">&lt;?xml
version="1.0" encoding="UTF-8"?&gt;

&lt;jboss-web&gt;

    &lt;context-root&gt;college_fest&lt;/context-root&gt;
    &lt;context-priority-classloader&gt;
      false
    &lt;/context-priority-classloader&gt;
&lt;/jboss-web&gt;</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>


<p><a href="#JBosstoGeronimo-ServletsandJSPsMigration-top">Back to Top</a></p>

<h2><a name="JBosstoGeronimo-ServletsandJSPsMigration-Deploythesampleapplication"></a>Deploy
the sample application</h2>
<p>The previous step showed how to deploy the application at build time by specifying
a customized <tt>jboss-build.xml</tt> file. If you used the default build.xml
file at build time you still need to deploy the College Fest application manually. To deploy
the College Fest application in JBoss, copy the <tt>college_fest.war</tt> file
you just built with Ant to the following directory:</p>

<p><tt>&lt;jboss_home&gt;\server\&lt;your_server_name&gt;\deploy</tt></p>

<p>If JBoss is already started, it will automatically deploy and start the application;
otherwise, the application will be deployed and started at the next startup.</p>

<p><a href="#JBosstoGeronimo-ServletsandJSPsMigration-top">Back to Top</a></p>

<h2><a name="JBosstoGeronimo-ServletsandJSPsMigration-Testingtheapplication"></a>Testing
the application <a name="JBosstoGeronimo-ServletsandJSPsMigration-test"></a></h2>
<p>To test the application, open a Web browser and access the following URL:</p>

<p><a href="http://localhost:8080/college_fest" rel="nofollow">http://localhost:8080/college_fest</a></p>

<p>You should see the Welcome screen where you can login with your name and college.
When you enter your name a college and click Submit you will see a message at the end on the
page stating your name with a link to "Click here" to enter the site. Browse the site and
check the options, at this point the College Fest application is configured and running.</p>

<p><a href="#JBosstoGeronimo-ServletsandJSPsMigration-top">Back to Top</a></p>

<h1><a name="JBosstoGeronimo-ServletsandJSPsMigration-TheGeronimoenvironment"></a>The
Geronimo environment <a name="JBosstoGeronimo-ServletsandJSPsMigration-Geronimo"></a></h1>
<p>Download and install Geronimo from the following URL:</p>

<p><a href="http://geronimo.apache.org/downloads.html" rel="nofollow">http://geronimo.apache.org/downloads.html</a></p>

<p>The release notes available there provide clear instructions on system requirements
and how to install and start Geronimo.  Throughout the rest of this article we will refer
to the Geronimo installation directory as <b>&lt;geronimo_home&gt;</b>.</p>

<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/forbidden.gif" width="16"
height="16" align="absmiddle" alt="" border="0"></td><td><b>TCP/IP ports
conflict</b><br />If you are planning to run JBoss and Geronimo on the same machine
consider to change the default service ports on, at least, one of these servers.</td></tr></table></div>

<p><a href="#JBosstoGeronimo-ServletsandJSPsMigration-top">Back to Top</a></p>

<h1><a name="JBosstoGeronimo-ServletsandJSPsMigration-Stepbystepmigration"></a>Step-by-step
migration <a name="JBosstoGeronimo-ServletsandJSPsMigration-migration"></a></h1>
<p>In order to migrate the College Fest application to Geronimo you need to replace
the <tt>jboss-web.xml</tt> file with a <tt>geronimo-web.xml</tt> file
which is the Geronimo specific descriptor file. The geronimo-web.xml file is located in the
WEB-INF directory withing the college_fest directory structure. The Geronimo deployment plan
geronimo-web.xml is illustrated in the following example.</p>

<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/warning.gif" width="16" height="16"
align="absmiddle" alt="" border="0"></td><td>The following geronimo-web.xml
was generated using the J2G tool.</td></tr></table></div>

<div class="code">
<textarea name="newcodemacro" class="xml:nocontrols:nogutter" rows="10" readonly="readonly">&lt;web-app
xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.1" 
         xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.1" 
         xmlns:security="http://geronimo.apache.org/xml/ns/security-1.1" 
         xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.1"&gt;
  &lt;sys:environment&gt;
    &lt;sys:moduleId&gt;
      &lt;sys:groupId&gt;j2g&lt;/sys:groupId&gt;
      &lt;sys:artifactId&gt;web-module&lt;/sys:artifactId&gt;
      &lt;sys:version&gt;1.0&lt;/sys:version&gt;
      &lt;sys:type&gt;war&lt;/sys:type&gt;
    &lt;/sys:moduleId&gt;
    &lt;sys:dependencies/&gt;
  &lt;/sys:environment&gt;
  &lt;context-root&gt;college_fest&lt;/context-root&gt;
&lt;/web-app&gt;</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>


<p>Given that College Fest is a very simple application, the Geronimo deployment plan
will also be very simple. Remember that this application does not use any database access
nor has security configured. While reading other articles in the <b>JBoss to Geronimo</b>
migration series, you will notice how the complexity of the deployment plan increases as the
sample applications for the different migration scenarios also grow in complexity.</p>

<p>Earlier in this article it was discussed the behavior of the <a href="#JBosstoGeronimo-ServletsandJSPsMigration-deploymentTool">deployment
tool</a>. During the deployment process, you provide to the deployment tool the application
module and a deployment plan. The College Fest sample application is so simple that you may
choose not to provide any deployment plan and let Geronimo do the deployment with a default
set of values (a default context root for example).</p>

<p>Last time you built the College Fest sample application it was configured for ant
to use the jboss-build.xml file instead of the default build.xml. The following example shows
the content of the default build.xml file.</p>

<div class="code">
<textarea name="newcodemacro" class="xml:nocontrols:nogutter" rows="10" readonly="readonly">&lt;?xml
version="1.0"?&gt;
&lt;!-- build file for building a war --&gt;

&lt;project name="build" default="war" basedir="."&gt;

    &lt;property file="build.properties"/&gt;
    &lt;property name="src.dir" value="src"/&gt;
    &lt;property name="dest.dir" value="bin"/&gt;


    &lt;target name="clean" description="Delete all generated files."&gt;
        &lt;echo message="Deleting bin folder" /&gt;
        &lt;delete dir="bin"/&gt;
    &lt;/target&gt;

      &lt;target name="compile"&gt;
    	&lt;mkdir dir="${dest.dir}"/&gt;

        &lt;javac srcdir="${src.dir}" destdir="${dest.dir}"&gt;
            &lt;classpath path="${java.home}/lib/tools.jar"/&gt;
            &lt;!--classpath path="${j2ee.home}/lib/j2ee.jar"/--&gt;
            &lt;classpath path="${geronimo.home}/repository/org/apache/geronimo/specs/geronimo-servlet_2.5_spec/1.1/geronimo-servlet_2.5_spec-1.1.jar"
/&gt;
        &lt;/javac&gt;
    &lt;/target&gt;

    &lt;target name="war" depends="compile"&gt;
        &lt;war destfile="college_fest.war" webxml="WEB-INF/web.xml"&gt;
            &lt;zipfileset dir="jsp" prefix="jsp"/&gt;
            &lt;zipfileset dir="pix" prefix="pix"/&gt;   	    
            &lt;classes dir="${dest.dir}"/&gt;    
            &lt;webinf dir="WEB-INF" /&gt;
        &lt;/war&gt;
&lt;/target&gt;


&lt;/project&gt;</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>


<p>To build the migrated application run <b>ant</b> from the command line
without specifying any additional parameters, a college_fest.war file will be created in the
root directory of the College Fest application directory structure.</p>

<p>To delete the generated files for a clean build run <b>ant clean</b>
followed by an <b>ant.</b></p>

<p><a href="#JBosstoGeronimo-ServletsandJSPsMigration-top">Back to Top</a></p>

<h2><a name="JBosstoGeronimo-ServletsandJSPsMigration-Deploythemigratedsampleapplication"></a>Deploy
the migrated sample application</h2>
<p>To deploy the migrated College Fest application, make sure the Geronimo server is
up and running. </p>

<p>From a command line, change directory to <tt>&lt;geronimo_home&gt;/bin</tt>
and type the following command:</p>

<p><b><tt>deploy --user system --password manager deploy &lt;college_fest_home&gt;/college_fest.war</tt></b></p>

<p>Once the application is deployed, open a Web browser and access the following URL:</p>

<p><a href="http://localhost:8080/college_fest/" rel="nofollow">http://localhost:8080/college_fest/</a></p>

<p>Repeat the steps you did when <a href="#JBosstoGeronimo-ServletsandJSPsMigration-test">Testing
the application</a> on the JBoss environment.</p>

<p><a href="#JBosstoGeronimo-ServletsandJSPsMigration-top">Back to Top</a></p>

<h1><a name="JBosstoGeronimo-ServletsandJSPsMigration-Summary"></a>Summary
<a name="JBosstoGeronimo-ServletsandJSPsMigration-summary"></a></h1>
<p>This article has shown you how to migrate a simple Servlet and JSPs application,
from JBoss to the Apache Geronimo application server. You followed step-by-step instructions
to build the application, deploy and run it, and then migrate it to the Geronimo environment.</p>

<p>Some remarks after reading this article:</p>
<ul>
	<li>Apache Geronimo provides two different Web containers, Jetty and Apache Tomcat.</li>
	<li>You learnt how to use the deployer too for deploying an application in Geronimo.</li>
	<li>Not always a Geronimo deployment plan is needed, if the application does not use
resource references you can accept the deployment defaults from Geronimo.</li>
</ul>

     </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/JBoss+to+Geronimo+-+Servlets+and+JSPs+Migration">View
Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=93344&revisedVersion=7&originalVersion=6">View
Change</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/GMOxDOC22/JBoss+to+Geronimo+-+Servlets+and+JSPs+Migration?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message