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 - EJB-BMP Migration (Unverified on 2.2)
Date Thu, 12 Nov 2009 08:11: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+-+EJB-BMP+Migration+%28Unverified+on+2.2%29">JBoss
to Geronimo - EJB-BMP Migration (Unverified on 2.2)</a></h2>
     <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~chirunhua@gmail.com">Runhua
Chi</a>
    </h4>
     
          <br/>
     <div class="notificationGreySide">
         <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
class='ScrollbarPrevIcon'><a href="/confluence/display/GMOxDOC22/Building+J2G+from+source"><img
border='0' align='middle' src='/confluence/images/icons/back_16.gif' width='16' height='16'></a></td><td
width='33%' class='ScrollbarPrevName'><a href="/confluence/display/GMOxDOC22/Building+J2G+from+source">Building
J2G from source</a>&nbsp;</td><td width='33%' class='ScrollbarParent'><sup><a
href="/confluence/display/GMOxDOC22/Migrating+from+JBoss+to+Geronimo"><img border='0'
align='middle' src='/confluence/images/icons/up_16.gif' width='8' height='8'></a></sup><a
href="/confluence/display/GMOxDOC22/Migrating+from+JBoss+to+Geronimo">Migrating from JBoss
to Geronimo</a></td><td width='33%' class='ScrollbarNextName'>&nbsp;<a
href="/confluence/display/GMOxDOC22/JBoss+to+Geronimo+-+EJB-Session+Beans+Migration+%28Unverified+on+2.1%29">JBoss
to Geronimo - EJB-Session Beans Migration (Unverified on 2.1)</a></td><td class='ScrollbarNextIcon'><a
href="/confluence/display/GMOxDOC22/JBoss+to+Geronimo+-+EJB-Session+Beans+Migration+%28Unverified+on+2.1%29"><img
border='0' align='middle' src='/confluence/images/icons/forwd_16.gif' width='16' height='16'></a></td></tr></table></div>
<p><a name="JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-top"></a><br/>
An entity bean is defined as a representation of persistent data that has the ability to read
from database and populate its fields with data. It can be updated and stored back to the
database. There are two types of Entity Beans that come with Enterprise Java Beans: Bean-Managed
Persistence(BMP) and Container-Managed Persistent(CMP). This article covers the migration
of a BMP sample application. For this type of entity bean, actual code must be written to
handle persistent operations such as loading, saving and finding data. The developer must
use persistence API such as JDBC to select, insert, update, delete from a database.</p>

<p>This article is organized in the following sections:</p>
<ul>
	<li><a href="#JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-analysis">BMP
implementation analysis</a></li>
	<li><a href="#JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-sample">Sample
application</a></li>
	<li><a href="#JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-jboss">The
JBoss environment</a></li>
	<li><a href="#JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-geronimo">The
Geronimo environment</a></li>
	<li><a href="#JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-migration">Step-by-step
migration</a></li>
	<li><a href="#JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-summary">Summary</a></li>
</ul>


<h1><a name="JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-BMPimplementationanalysis"></a>BMP
implementation analysis <a name="JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-analysis"></a></h1>

<p>BMP implementation may vary from one vendor to another. The purpose of this section
is to provide a BMP specific feature-to-feature comparison between JBoss v4.0.5 and Apache
Geronimo, so that you can clearly identify the differences and plan accordingly before migration.</p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>Features</th>
<th class='confluenceTh'>JBoss v4.2.1</th>
<th class='confluenceTh'>Apache Geronimo</th>
</tr>
<tr>
<td class='confluenceTd'>EJB Container</td>
<td class='confluenceTd'>JBoss comes with its own implementation</td>
<td class='confluenceTd'>Geronimo uses OpenEJB as its EJB Container</td>
</tr>
</tbody></table>

<p><a href="#JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-top">Back to
Top</a></p>

<h1><a name="JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-Sampleapplication"></a>Sample
application <a name="JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-sample"></a></h1>

<p>This is a simple loan registration application which allows users to apply for loans
and administrators to approve/reject the loans. Customers can apply for loans using the Web
site while the manager uses a simple Java application to approval/reject loans. BMP Entity
Bean has been used to manage Loan related persistence data from a database. In addition to
that a Stateless Session Bean has been used handle work flow related activities. </p>

<p>The following figure illustrates the loan management Web application flow:<br/>
<div align="center"><img src="/confluence/download/attachments/93433/loan_web_overview.gif"
border="0" /></div></p>

<p>First page of the loan registration Web application acts as a notice board which
displays list of loans and their current status. When a customer decides to apply for a Loan,
he/she can use loan registration form. After the registration of the loan, it is categorized
under pending status. A manager who has the administrator privileges will use a small application
to change the status of loans. Using this application, the manager can change the status of
pending loans to either approved or rejected. </p>

<h2><a name="JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-ApplicationclassesandJSPpages"></a>Application
classes and JSP pages</h2>

<ul>
	<li>org.apache.geronimo.samples.loan.client
	<ul>
		<li>LoanStatusChanger - Standalone application which helps to approve applied loans.</li>
	</ul>
	</li>
	<li>org.apache.geronimo.samples.loan.dto
	<ul>
		<li>LoanDTO - Data transfer object for loan related information between Web and EJB
tiers.</li>
	</ul>
	</li>
	<li>org.apache.geronimo.samples.loan.ejb
	<ul>
		<li>LoanBean - BMP to handle loan related persistence data from the database.</li>
		<li>LoanManagerBean - Stateless session bean to handle .</li>
	</ul>
	</li>
	<li>org.apache.geronimo.samples.loan.util
	<ul>
		<li>PropertyLoader - Loads application server related properties to the different
types of clients.</li>
	</ul>
	</li>
	<li>org.apache.geronimo.samples.loan.web
	<ul>
		<li>LoanManagerDispatchServlet - A servlet to dispatch loan handling related activities
from front end to Web tier.</li>
	</ul>
	</li>
</ul>


<p>This loan management web application also includes the following JSP pages:</p>
<ul>
	<li>error.jsp -  Common error page to handle unexpected conditions.</li>
	<li>index.jsp - Forward in to the list of loans in the application.</li>
	<li>list_loans.jsp - List of loans and their information are displayed.</li>
	<li>register_loan.jsp - Loan registration form to be filled by a customer.</li>
</ul>


<h2><a name="JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-Toolsused"></a>Tools
used</h2>
<p>The tools used for developing and building the Loan Manager application are:</p>

<h3><a name="JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-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-EJB-BMPMigration%28Unverifiedon2.2%29-ApacheAnt"></a>Apache
Ant</h3>
<p>Ant is a pure Java build tool. It is used for building the war files and populating
the database for the Online Brokerage 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-EJB-BMPMigration%28Unverifiedon2.2%29-top">Back to
Top</a></p>

<h1><a name="JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-TheJBossenvironment"></a>The
JBoss environment <a name="JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-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. Note that for this migration example
JBoss v4.2.1 was used.</p>

<p>Detailed instructions for installing, configuring, and managing JBoss are provided
in the product documentation. Check the product Web site 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.2.1 as explained in the product documentation guides.
From now on the installation directory will be referred as <b>&lt;jboss_home&gt;</b></li>
	<li>Create a copy of the default JBoss v4.2.1 application server. Copy recursively
<b>&lt;jboss_home&gt;\server\default</b> to <b>&lt;jboss_home&gt;\server\&lt;your_server_name&gt;</b></li>
	<li>Start the new server by running the <b>run.sh -c &lt;your_server_name&gt;</b>
command from the <b>&lt;jboss_home&gt;\bin</b> 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>


<h2><a name="JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-Installandconfigureprerequisitesoftware"></a>Install
and configure prerequisite software</h2>
<p>In order to build and run the Loan Management application included in this article,
you will need to install and configure the build tool and the database that is used by the
application.</p>

<h3><a name="JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-Modifydatabasesettings"></a>Modify
database settings</h3>

<p>This application is using the HSQL database that comes as part of the JBoss bundle.
You need to modify the script for creating the database. Edit the <b>localDB.script</b>
file located in the <b>&lt;jboss_home&gt;\server\&lt;your_server_name&gt;\data\hypersonic</b>
directory:</p>

<p>Add the top of the <b>localDB.script</b> file the content of the following
example in order to create the sample HSQL database. Also add the sample data to the same
file at the end given in the <b>config/db.sql</b> under the JBoss Specific Data.</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><b>Make sure JBoss is not
running at the time of modifying this file.</b></td></tr></table></div>

<h3><a name="JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-ConfigureAnt"></a>Configure
Ant</h3>

<p>As mentioned before, Apache Ant is used to build the binaries for the Online Brokerage
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>

<h3><a name="JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-ConfigureXDoclet"></a>Configure
XDoclet</h3>

<p>XDoclet is going to be used as build tool for the configuration file generation.
It  is an open source code generation engine. It enables Attribute-Oriented Programming for
Java. In short, this means that you can add more significance to your code by adding meta
data (attributes) to your Java sources. This is done in special JavaDoc tags.<br/>
Although XDoclet originated as a tool for creating EJBs, it has evolved into a general-purpose
code generation engine. XDoclet consists of a core and a constantly growing number of modules.
It is fairly straight forward to write new modules if there is a need for a new kind of component.<br/>
<a href="http://xdoclet.sourceforge.net/xdoclet/index.html" rel="nofollow">http://xdoclet.sourceforge.net/xdoclet/index.html</a></p>

<p>Just extract the latest version of the XDoclet and set the <b>xdoclet.home</b>
parameter in to the <b>build.properties</b> file.</p>

<h2><a name="JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-Buildthesampleapplication"></a>Build
the sample application</h2>

<p>The loan manager application included with this article provides an Ant script that
you will use in order to build the application. Download the loan manager application from
the following link:</p>

<p><a href="/confluence/download/attachments/93433/loan.zip?version=1">Loan</a></p>

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

<div class="code panel" style="border-style: solid;border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;"><b>build.properties</b></div><div
class="codeContent panelContent">
<pre class="code-xml">
## Set the Geronimo 2.0 home here
geronimo.home=<span class="code-tag">&lt;geronimo_home&gt;</span>

## Set XDoclet 1.2.3 Home 
xdoclet.home=<span class="code-tag">&lt;xdoclet_home&gt;</span>
</pre>
</div></div>

<p>Before starting the build process just set the correct paths for the <b>geronimo.home</b>
and <b>xdoclet.home</b> entries in the <b>build.properties</b> file
in the <b>config</b> directory.</p>

<p>From a command prompt or shell go to the <b>loan</b> directory and run
<b>ant jboss</b>. This will build the ear file and place it directly in the <b>releases/jboss</b>
directory.</p>


<h2><a name="JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-Deploythesampleapplication"></a>Deploy
the sample application</h2>

<p>To deploy the sample application just copy the <b>Loan.ear</b> will be
created under the <b>loan/releases/jboss</b> folder to the <b>&lt;jboss_home&gt;/server/&lt;your_server_name&gt;/deploy</b>
folder. </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>

<h2><a name="JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-Testthesampleapplication"></a>Test
the sample application</h2>

<p>To test the application, open a Web browser and access the following URL:</p>

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

<p>This brings up the loan manager main page with the list of loans and their current
statuses.<b>Register</b> link will forward you to the loan registration form which
accepts number of fields before adding loans in to the loan information database. </p>

<p><div align="center"><img src="/confluence/download/attachments/93433/loan_screen.gif"
border="0" /></div></p>

<p>To change the status of a loan, manager has to find the loan ID from the Web application
and has to provide it in the client application as given below.</p>

<p><b>java -jar LoanStatusChanger.jar &lt;loanId&gt; &lt;status&gt;</b></p>

<p>Status filed will change according to the following values. The following are the
status values of relevant loans.</p>
<ol>
	<li>0 - Pending</li>
	<li>1 - Accepted</li>
	<li>Other - Rejected</li>
</ol>


<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>Make sure you add the <b>&lt;jboss-home&gt;/client/jbossall-client.jar</b>
file to your class path before running the above command.</td></tr></table></div>

<p><a href="#JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-top">Back to
Top</a></p>

<h1><a name="JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-TheGeronimoenvironment"></a>The
Geronimo environment <a name="JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-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 /><p>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.</p></td></tr></table></div>


<p><a href="#JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-top">Back to
Top</a></p>
<h1><a name="JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-Stepbystepmigration"></a>Step-by-step
migration <a name="JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-migration"></a></h1>

<p>When you built the loan manager sample application, Ant packaged the deployment descriptors
for both JBoss <b>jboss.xml</b> and Geronimo <b>openejb-jar.xml</b>
as they were already provided by the sample application. These files are located in the <b>loan/config</b>
directory.</p>

<p>The following example shows the JBoss deployment descriptor.</p>

<div class="code panel" style="border-style: solid;border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;"><b>jboss.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;!DOCTYPE jboss PUBLIC <span class="code-quote">"-//JBoss//DTD
JBOSS 4.0//EN"</span> <span class="code-quote">"http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd"</span>&gt;</span>

<span class="code-tag">&lt;jboss&gt;</span>

   <span class="code-tag">&lt;enterprise-beans&gt;</span>

      <span class="code-tag">&lt;entity&gt;</span>
         <span class="code-tag">&lt;ejb-name&gt;</span>Loan<span class="code-tag">&lt;/ejb-name&gt;</span>
         <span class="code-tag">&lt;local-jndi-name&gt;</span>Loan<span
class="code-tag">&lt;/local-jndi-name&gt;</span>
        <span class="code-tag">&lt;method-attributes&gt;</span>
        <span class="code-tag">&lt;/method-attributes&gt;</span>
      <span class="code-tag">&lt;/entity&gt;</span>

      <span class="code-tag">&lt;session&gt;</span>
         <span class="code-tag">&lt;ejb-name&gt;</span>LoanManager<span
class="code-tag">&lt;/ejb-name&gt;</span>
         <span class="code-tag">&lt;jndi-name&gt;</span>org.apache.geronimo.samples.loan.ejb.LoanManager<span
class="code-tag">&lt;/jndi-name&gt;</span>
         <span class="code-tag">&lt;local-jndi-name&gt;</span>LoanManager<span
class="code-tag">&lt;/local-jndi-name&gt;</span>
        <span class="code-tag">&lt;method-attributes&gt;</span>
        <span class="code-tag">&lt;/method-attributes&gt;</span>
      <span class="code-tag">&lt;/session&gt;</span>

   <span class="code-tag">&lt;/enterprise-beans&gt;</span>

   <span class="code-tag">&lt;resource-managers&gt;</span>
   <span class="code-tag">&lt;/resource-managers&gt;</span>
  
<span class="code-tag">&lt;/jboss&gt;</span>
</pre>
</div></div>

<p>Compare it with the contents of the Geronimo deployment plan shown in the following
example.</p>

<div class="code panel" style="border-style: solid;border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;"><b>openejb-jar.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;openejb-jar xmlns=<span class="code-quote">"http://www.openejb.org/xml/ns/openejb-jar-2.1"</span>&gt;</span>
	<span class="code-tag">&lt;dep:environment <span class="code-keyword">xmlns:dep</span>=<span
class="code-quote">"http://geronimo.apache.org/xml/ns/deployment-1.2"</span>&gt;</span>
		<span class="code-tag">&lt;dep:moduleId&gt;</span>
			<span class="code-tag">&lt;dep:groupId&gt;</span>org.apache.geronimo.samples<span
class="code-tag">&lt;/dep:groupId&gt;</span>
			<span class="code-tag">&lt;dep:artifactId&gt;</span>LoanManagerEJB<span
class="code-tag">&lt;/dep:artifactId&gt;</span>
			<span class="code-tag">&lt;dep:version&gt;</span>1.0<span class="code-tag">&lt;/dep:version&gt;</span>
			<span class="code-tag">&lt;dep:type&gt;</span>car<span class="code-tag">&lt;/dep:type&gt;</span>
		<span class="code-tag">&lt;/dep:moduleId&gt;</span>
		<span class="code-tag">&lt;dep:dependencies/&gt;</span>
		<span class="code-tag">&lt;dep:hidden-classes/&gt;</span>
		<span class="code-tag">&lt;dep:non-overridable-classes/&gt;</span>
	<span class="code-tag">&lt;/dep:environment&gt;</span>
	<span class="code-tag">&lt;enterprise-beans&gt;</span>
		<span class="code-tag">&lt;session&gt;</span>
			<span class="code-tag">&lt;ejb-name&gt;</span>LoanManager<span class="code-tag">&lt;/ejb-name&gt;</span>
			<span class="code-tag">&lt;ejb-ref&gt;</span>
				<span class="code-tag">&lt;ref-name&gt;</span>ejb/LoanLocal<span
class="code-tag">&lt;/ref-name&gt;</span>
				<span class="code-tag">&lt;ejb-link&gt;</span>Loan<span class="code-tag">&lt;/ejb-link&gt;</span>
			<span class="code-tag">&lt;/ejb-ref&gt;</span>
		<span class="code-tag">&lt;/session&gt;</span>
		<span class="code-tag">&lt;entity&gt;</span>
			<span class="code-tag">&lt;ejb-name&gt;</span>Loan<span class="code-tag">&lt;/ejb-name&gt;</span>
		
			<span class="code-tag">&lt;resource-ref&gt;</span>
				<span class="code-tag">&lt;ref-name&gt;</span>jdbc/LoanDataSource<span
class="code-tag">&lt;/ref-name&gt;</span>
				<span class="code-tag">&lt;resource-link&gt;</span>SystemDatasource<span
class="code-tag">&lt;/resource-link&gt;</span>
			<span class="code-tag">&lt;/resource-ref&gt;</span>
		<span class="code-tag">&lt;/entity&gt;</span>
	<span class="code-tag">&lt;/enterprise-beans&gt;</span>
<span class="code-tag">&lt;/openejb-jar&gt;</span>
</pre>
</div></div>

<p>First difference can be clearly noted is Geronimo specific configuration has additional
information than JBoss specific one. That part of the Geronimo configuration file is quite
similar to a Maven 2 build script. Both of these given configuration files have EJB information.
JBoss uses local JNDI names to link the EJBs while Geronimo directly use the EJB's name. In
addition to above differences the <b>openejb-jar.xml</b> file clearly gives the
EJB reference information than the <b>jboss.xml</b> file.</p>

<p>The Web archive related configuration files give you few more differences.</p>

<div class="code panel" style="border-style: solid;border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;"><b>jboss-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;jboss-web&gt;</span>

	<span class="code-tag">&lt;ejb-local-ref&gt;</span>
		<span class="code-tag">&lt;ejb-ref-name&gt;</span>ejb/LoanManagerLocal<span
class="code-tag">&lt;/ejb-ref-name&gt;</span>
		<span class="code-tag">&lt;local-jndi-name&gt;</span>LoanManager<span
class="code-tag">&lt;/local-jndi-name&gt;</span>
	<span class="code-tag">&lt;/ejb-local-ref&gt;</span>  
<span class="code-tag">&lt;/jboss-web&gt;</span>
</pre>
</div></div>

<div class="code panel" style="border-style: solid;border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;"><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.1"</span>
<span class="code-keyword">xmlns:naming</span>=<span class="code-quote">"http://geronimo.apache.org/xml/ns/naming-1.1"</span>&gt;</span>
  <span class="code-tag">&lt;dep:environment <span class="code-keyword">xmlns:dep</span>=<span
class="code-quote">"http://geronimo.apache.org/xml/ns/deployment-1.1"</span>&gt;</span>
    <span class="code-tag">&lt;dep:moduleId&gt;</span>
      <span class="code-tag">&lt;dep:groupId&gt;</span>org.apache.geronimo.samples<span
class="code-tag">&lt;/dep:groupId&gt;</span>
      <span class="code-tag">&lt;dep:artifactId&gt;</span>LoanManagerWeb<span
class="code-tag">&lt;/dep:artifactId&gt;</span>
      <span class="code-tag">&lt;dep:version&gt;</span>1.0<span class="code-tag">&lt;/dep:version&gt;</span>
      <span class="code-tag">&lt;dep:type&gt;</span>car<span class="code-tag">&lt;/dep:type&gt;</span>
    <span class="code-tag">&lt;/dep:moduleId&gt;</span>
    <span class="code-tag">&lt;dep:dependencies/&gt;</span>	
    <span class="code-tag">&lt;dep:hidden-classes/&gt;</span>
    <span class="code-tag">&lt;dep:non-overridable-classes/&gt;</span>
  <span class="code-tag">&lt;/dep:environment&gt;</span>
 
  <span class="code-tag">&lt;naming:ejb-local-ref&gt;</span>
	  <span class="code-tag">&lt;naming:ref-name&gt;</span>ejb/LoanManagerLocal<span
class="code-tag">&lt;/naming:ref-name&gt;</span>
	  <span class="code-tag">&lt;naming:ejb-link&gt;</span>LoanManager<span
class="code-tag">&lt;/naming:ejb-link&gt;</span>
  <span class="code-tag">&lt;/naming:ejb-local-ref&gt;</span>
	
<span class="code-tag">&lt;/web-app&gt;</span>
</pre>
</div></div>

<p><b>jboss-web.xml</b> maps the EJBs using JNDI names as given above while
<b>geronimo-web.xml</b> directly uses the EJB's name. The reference names given
in each mapping will be used refer EJBs from the Servlets. <b>web.xml</b> file
of the WAR file contains more information about each EJB reference name, which will be common
to the both Geronimo and JBoss flavors of this application.</p>

<h2><a name="JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-Buildthesampleapplication"></a>Build
the sample application</h2>

<p>Build the migrated Geronimo version of the sample application by running following
command from the <b>loan</b> directory.<br/>
<b>ant geronimo</b><br/>
It will create <b>Loan.ear</b> file in the <b>loan/releases/geronimo</b>
folder.</p>

<h2><a name="JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-Deploythemigratedapplication"></a>Deploy
the migrated application</h2>

<p>To deploy the migrated Loan Manager application, make sure the Geronimo server is
up and running and user has to populate the database and then deploy the sample application.</p>

<h3><a name="JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-PopulatingtheDatabase"></a>Populating
the Database</h3>
<p>This sample application will use the default Geronimo System database to hold the
application specific data.<br/>
In the Geronimo console follow given steps.</p>
<ol>
	<li>Select DB Manager link from the Console Navigation in the left.</li>
	<li>Select the <b>SystemDatabase</b> to <b>Use DB</b> field.</li>
	<li>Open <b>db.sql</b> in the <b>loan/config</b> directory
from a text editor and copy the content below Geronimo Specific Database SQLs.</li>
	<li>Paste the content the given above SQL Commands text area and press Run SQL button.</li>
</ol>


<h3><a name="JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-DeploySampleApplication"></a>Deploy
Sample Application</h3>
<p>Open Geronimo console in your browser and follow the given steps:</p>
<ol>
	<li>Scroll down to <b>Deploy New</b> from the <b>Console Navigation</b>
panel.</li>
	<li>Load <b>loan.ear</b> from <b>loan/releases/geronimo</b>
folder in to the <b>Archive</b> input box.</li>
	<li>Press <b>Install</b> button to deploy application in the server.</li>
</ol>


<h2><a name="JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-Testthesampleapplication"></a>Test
the sample application</h2>

<p>To test the application, open a Web browser and access the following URL:</p>

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

<p>To change the status of a loan, the user has to find the loan ID from the Web application
and has to provide it in the client application as given below.</p>

<p><b>java -jar LoanStatusChanger.jar &lt;loanId&gt; &lt;status&gt;</b></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><p>Make sure you add the
following list of JAR files to your class path before running the above command.</p>
<ol>
	<li>geronimo-kernel-2.0.x.jar</li>
	<li>geronimo-j2ee_connector_1.5_spec-1.x.x.jar</li>
	<li>geronimo-j2ee_management_1.1_spec-1.x.jar</li>
	<li>geronimo-security-2.0.x.jar</li>
	<li>cglib-nodep-2.1_3.jar</li>
	<li>openejb-core-3.0.jar</li>
</ol>
</td></tr></table></div>

<p><a href="#JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-top">Back to
Top</a></p>

<h1><a name="JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-Summary"></a>Summary
<a name="JBosstoGeronimo-EJB-BMPMigration%28Unverifiedon2.2%29-summary"></a></h1>
<p>This article has shown how to migrate a sample application that uses BMP entity beans,
from JBoss v4.2.1 to Apache Geronimo. This article provided step-by-step instructions to build
the application, deploy and run it, and then migrate it to the Geronimo environment.</p>

<p>The following list summarizes the major differences found during this sample application
migration.</p>

<ul>
	<li>In order to deploy an EJB jar file in JBoss you need to just copy the configuration
file to the deploy directory but in Geronimo you can use either deployer tool, console or
hot deployment directory.</li>
	<li>The contents of the deployment plans for EJB jar files in JBoss and in Geronimo
are almost similar except for the starting part of the Geronimo which is more similar to a
Maven 2 build file.</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+-+EJB-BMP+Migration+%28Unverified+on+2.2%29">View
Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=93433&revisedVersion=3&originalVersion=2">View
Change</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/GMOxDOC22/JBoss+to+Geronimo+-+EJB-BMP+Migration+%28Unverified+on+2.2%29?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message