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.1 > 5-minute Tutorial on Enterprise Application Development with Eclipse and Geronimo
Date Tue, 04 Jan 2011 02:42:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1810/9/1/_/styles/combined.css?spaceKey=GMOxDOC21&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/GMOxDOC21/5-minute+Tutorial+on+Enterprise+Application+Development+with+Eclipse+and+Geronimo">5-minute
Tutorial on Enterprise Application Development with Eclipse and Geronimo</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~maojia508">maojia</a>
    </h4>
        <br/>
                         <h4>Changes (1)</h4>
                                 
    
<div id="page-diffs">
            <table class="diff" cellpadding="0" cellspacing="0">
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" > <br>{note:title=Important}
<br></td></tr>
            <tr><td class="diff-changed-lines" >When workng on versions pervious
to Geronimo 2.1.7, remove *ejbModule/META-INF/openejb-jar.xml* file in the SampleEJB project
as it causes deployment issues. See the file highlighted in the image above. However, when
using Geronimo 2.1.7, you must include this *ejbModule/META-INF/openejb-jar.xml* file or else
you will encounter NullPointerException error due to a <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">bug
issue.</span> <span class="diff-added-words"style="background-color: #dfd;">[bug
issue|https://issues.apache.org/jira/browse/GERONIMODEVTOOLS-689].</span> <br></td></tr>
            <tr><td class="diff-unchanged" >{note} <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
        </table>
</div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <p>This tutorial walks you through configuring, developing and deploying an
enterprise application with Eclipse and Geronimo. To run this tutorial, as a minimum you will
be required to have installed the following prerequisite software.</p>

<ul>
	<li>Sun JDK 5.0+ (J2SE 1.5)</li>
	<li>Eclipse 3.3.1.1 (Eclipse Classic package of Europa distribution), which is platform
specific</li>
	<li>Web Tools Platform (WTP) 2.0.1</li>
	<li>Data Tools Platform (DTP) 1.5.1</li>
	<li>Eclipse Modeling Framework (EMF) 2.3.1</li>
	<li>Graphical Editing Framework (GEF) 3.3.1</li>
</ul>


<p>Details on installing eclipse are provided in the <a href="/confluence/display/GMOxDOC21/Development+environment"
title="Development environment">Development environment</a> section. This tutorial
is organized in the following sections:</p>

<div>
<ul>
    <li><a href='#5-minuteTutorialonEnterpriseApplicationDevelopmentwithEclipseandGeronimo-CreateEnterpriseApplicationProject'>Create
Enterprise Application Project</a></li>
    <li><a href='#5-minuteTutorialonEnterpriseApplicationDevelopmentwithEclipseandGeronimo-CreateEJBproject'>Create
EJB project</a></li>
    <li><a href='#5-minuteTutorialonEnterpriseApplicationDevelopmentwithEclipseandGeronimo-CreateDynamicWebProject'>Create
Dynamic Web Project</a></li>
    <li><a href='#5-minuteTutorialonEnterpriseApplicationDevelopmentwithEclipseandGeronimo-CreateStatelessSessionEJB'>Create
Stateless Session EJB</a></li>
<ul>
    <li><a href='#5-minuteTutorialonEnterpriseApplicationDevelopmentwithEclipseandGeronimo-Createremotebusinessinterface'>Create
remote business interface</a></li>
    <li><a href='#5-minuteTutorialonEnterpriseApplicationDevelopmentwithEclipseandGeronimo-Createbeanclass'>Create
bean class</a></li>
</ul>
    <li><a href='#5-minuteTutorialonEnterpriseApplicationDevelopmentwithEclipseandGeronimo-Webapplicationdevelopment'>Web
application development</a></li>
<ul>
    <li><a href='#5-minuteTutorialonEnterpriseApplicationDevelopmentwithEclipseandGeronimo-Createwelcomepageindex.jsp'>Create
welcome page - index.jsp</a></li>
    <li><a href='#5-minuteTutorialonEnterpriseApplicationDevelopmentwithEclipseandGeronimo-CreateservletMyServlet'>Create
servlet - MyServlet</a></li>
</ul>
    <li><a href='#5-minuteTutorialonEnterpriseApplicationDevelopmentwithEclipseandGeronimo-Runit%21'>Run
it!</a></li>
</ul></div>

<h1><a name="5-minuteTutorialonEnterpriseApplicationDevelopmentwithEclipseandGeronimo-CreateEnterpriseApplicationProject"></a>Create
Enterprise Application Project</h1>

<p>Start from creating an enterprise application project from the eclipse workspace.</p>

<ol>
	<li>Select <b>File</b> -&gt; <b>New</b>, select <b>Project...</b>
and in the popup window select select <b>Enterprise Application Project</b> in
<b>J2EE</b> category and click <b>Next</b>.</li>
	<li>In the EAR Application Project wizard type in <b>SampleEAR</b> as the
<b>Project name:</b> and select <b>Apache Geronimo v2.1</b> in <b>Target
Runtime</b>. Leave the rest as it is.
<br class="atl-forced-newline" /> <br class="atl-forced-newline" /> <span class="image-wrap"
style=""><img src="/confluence/download/attachments/76337/ear_prj_1.1.jpg?version=1&amp;modificationDate=1202928149000"
style="border: 0px solid black" /></span> <br class="atl-forced-newline" />
<br class="atl-forced-newline" /></li>
	<li>Click <b>Next</b> twice.</li>
	<li>In the <b>J2EE Modules to Add to the EAR</b> window select the <b>Generate
Deployment Descriptor</b> checkbox and click <b>Next</b>.
<br class="atl-forced-newline" /> <br class="atl-forced-newline" /> <span class="image-wrap"
style=""><img src="/confluence/download/attachments/76337/ear_prj_2.jpg?version=1&amp;modificationDate=1202908775000"
style="border: 0px solid black" /></span> <br class="atl-forced-newline" />
<br class="atl-forced-newline" /></li>
	<li>In the <b>Geronimo Deployment Plan</b> window enter the values as specified
below. To find out more about what these values mean check the <a href="/confluence/display/GMOxDOC21/Deployment+plans"
title="Deployment plans">Deployment plans</a> section.
<table class="sectionMacro" border="0" cellpadding="5" cellspacing="0" width="100%"><tbody><tr><ul>
	<li>Group Id: <b>sampleear</b></li>
	<li>Artifact Id: <b>sample-ear</b></li>
	<li>Version: <b>1.0</b></li>
	<li>Artifact Type: <b>ear</b></li>
</ul>
</tr></tbody></table>
<p><br class="atl-forced-newline" /> <span class="image-wrap" style=""><img
src="/confluence/download/attachments/76337/ear_prj_3.jpg?version=1&amp;modificationDate=1202908775000"
style="border: 0px solid black" /></span> <br class="atl-forced-newline" />
<br class="atl-forced-newline" /></p></li>
	<li>Click <b>Finish</b>.</li>
</ol>


<p>If asked about changing to the Java EE perspective, click <b>Yes</b>.
You may want to select the <b>Remember my decision</b> checkbox to avoid dealing
with it in the future.</p>

<p>You should now have the following project structure.
<br class="atl-forced-newline" /> <br class="atl-forced-newline" /> <span class="image-wrap"
style=""><img src="/confluence/download/attachments/76337/ear_prj_4.1.jpg?version=1&amp;modificationDate=1202928148000"
style="border: 0px solid black" /></span> <br class="atl-forced-newline" /></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>Error message</b><br
/>Don't worry about the error <b>cvc-complex-type.2.4.b: The content of element 'application'
is not complete...</b> for now. We'll fix it in the next step when you define an ejb
module (and webapp module afterwards).</td></tr></table></div>

<h1><a name="5-minuteTutorialonEnterpriseApplicationDevelopmentwithEclipseandGeronimo-CreateEJBproject"></a>Create
EJB project</h1>
<p>The next step is to create an EJB project to hold your EJBs.</p>

<ol>
	<li>Press <b>Ctrl-N</b>, select <b>EJB Project</b> in <b>EJB</b>
category and click <b>Next</b>.</li>
	<li>In the EJB Project wizard type in <b>SampleEJB</b> as the project name
and select <b>Add project to an EAR</b> checkbox. Leave the rest as is and click
<b>Next</b>.
<br class="atl-forced-newline" /> <br class="atl-forced-newline" /> <span class="image-wrap"
style=""><img src="/confluence/download/attachments/76337/ejb_prj_1.1.jpg?version=1&amp;modificationDate=1202928148000"
style="border: 0px solid black" /></span> <br class="atl-forced-newline" />
<br class="atl-forced-newline" /></li>
	<li>Make sure that <b>5.0</b> for the <b>Java</b> facet in
the <b>Project Facets</b> popup window's selected and click <b>Next</b>.
<br class="atl-forced-newline" /> <br class="atl-forced-newline" /> <span class="image-wrap"
style=""><img src="/confluence/download/attachments/76337/ejb_prj_2.jpg?version=1&amp;modificationDate=1202909989000"
style="border: 0px solid black" /></span> <br class="atl-forced-newline" />
<br class="atl-forced-newline" /></li>
	<li>Unselect the <b>Create an EJB Client JAR module to hold the client interfaces
and classes</b> checkbox. We're not interested in it. Click <b>Next</b>.
<br class="atl-forced-newline" /> <br class="atl-forced-newline" /> <span class="image-wrap"
style=""><img src="/confluence/download/attachments/76337/ejb_prj_3.jpg?version=1&amp;modificationDate=1202909989000"
style="border: 0px solid black" /></span> <br class="atl-forced-newline" />
<br class="atl-forced-newline" /></li>
	<li>Fill in the Geronimo Deployment Plan fields with the following values:
<table class="sectionMacro" border="0" cellpadding="5" cellspacing="0" width="100%"><tbody><tr><ul>
	<li>Group Id: <b>sampleear</b></li>
	<li>Artifact Id: <b>sample-ejb</b></li>
	<li>Artifact Type: <b>ejb</b></li>
</ul>
</tr></tbody></table>
<p><br class="atl-forced-newline" /> <span class="image-wrap" style=""><img
src="/confluence/download/attachments/76337/ejb_prj_4.jpg?version=1&amp;modificationDate=1202909989000"
style="border: 0px solid black" /></span> <br class="atl-forced-newline" />
<br class="atl-forced-newline" /></p></li>
	<li>Click <b>Finish</b>.</li>
</ol>


<p>You should now have the following project structure.
<br class="atl-forced-newline" /> <br class="atl-forced-newline" /> <span class="image-wrap"
style=""><img src="/confluence/download/attachments/76337/ejb_prj_5.1.jpg?version=1&amp;modificationDate=1202928148000"
style="border: 0px solid black" /></span> <br class="atl-forced-newline" /></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>Important</b><br
/>When workng on versions pervious to Geronimo 2.1.7, remove <b>ejbModule/META-INF/openejb-jar.xml</b>
file in the SampleEJB project as it causes deployment issues. See the file highlighted in
the image above. However, when using Geronimo 2.1.7, you must include this <b>ejbModule/META-INF/openejb-jar.xml</b>
file or else you will encounter NullPointerException error due to a <a href="https://issues.apache.org/jira/browse/GERONIMODEVTOOLS-689"
class="external-link" rel="nofollow">bug issue</a>.</td></tr></table></div>

<h1><a name="5-minuteTutorialonEnterpriseApplicationDevelopmentwithEclipseandGeronimo-CreateDynamicWebProject"></a>Create
Dynamic Web Project</h1>

<p>Now that you have EAR and EJB projects created the next step is to create a Dynamic
Web project to hold your web application.</p>

<ol>
	<li>Press <b>Ctrl-N</b>,  select <b>Dynamic Web Project</b>
in <b>Web</b> category and click <b>Next</b>.</li>
	<li>In the Dynamic Web Project wizard type in <b>SampleWAR</b> as the project
name and select <b>Add project to an EAR</b> checkbox. Leave the rest as is and
click <b>Next</b>.
<br class="atl-forced-newline" /> <br class="atl-forced-newline" /> <span class="image-wrap"
style=""><img src="/confluence/download/attachments/76337/war_prj_1.1.jpg?version=1&amp;modificationDate=1202928148000"
style="border: 0px solid black" /></span> <br class="atl-forced-newline" />
<br class="atl-forced-newline" /></li>
	<li>Make sure that <b>5.0</b> for the <b>Java</b> facet in
the <b>Project Facets</b> popup window's selected and click <b>Next</b>
twice.
<br class="atl-forced-newline" /> <br class="atl-forced-newline" /> <span class="image-wrap"
style=""><img src="/confluence/download/attachments/76337/war_prj_2.jpg?version=1&amp;modificationDate=1202918003000"
style="border: 0px solid black" /></span> <br class="atl-forced-newline" />
<br class="atl-forced-newline" /></li>
	<li>Fill in the Geronimo Deployment Plan fields with the following values:
<table class="sectionMacro" border="0" cellpadding="5" cellspacing="0" width="100%"><tbody><tr><ul>
	<li>Group Id: <b>sampleear</b></li>
	<li>Artifact Id: <b>sample-war</b></li>
	<li>Artifact Type: <b>war</b></li>
</ul>
</tr></tbody></table>
<p><br class="atl-forced-newline" /> <span class="image-wrap" style=""><img
src="/confluence/download/attachments/76337/war_prj_3.jpg?version=1&amp;modificationDate=1202918003000"
style="border: 0px solid black" /></span> <br class="atl-forced-newline" />
<br class="atl-forced-newline" /></p></li>
	<li>Click <b>Finish</b>.</li>
</ol>


<p>You should now have the following project structure.
<br class="atl-forced-newline" /> <br class="atl-forced-newline" /> <span class="image-wrap"
style=""><img src="/confluence/download/attachments/76337/war_prj_4.1.jpg?version=1&amp;modificationDate=1202928234000"
style="border: 0px solid black" /></span> <br class="atl-forced-newline" /></p>

<h1><a name="5-minuteTutorialonEnterpriseApplicationDevelopmentwithEclipseandGeronimo-CreateStatelessSessionEJB"></a>Create
Stateless Session EJB</h1>

<p>Every stateless session ejb has its own business interface. There are three types
of business interfaces - <b><tt>@Remote</tt></b>, <b><tt>@Local</tt></b>
and <b><tt>@WebService</tt></b> - and combinations of these three.
No need to say that every EJB development starts from defining a business interface and implementing
it by a bean implementation class so, that is exactly what we will be doing in the next steps.</p>

<h2><a name="5-minuteTutorialonEnterpriseApplicationDevelopmentwithEclipseandGeronimo-Createremotebusinessinterface"></a>Create
remote business interface</h2>

<ol>
	<li>Right-click on the <b>SampleEJB</b> project and select <b>New</b>
-&gt; <b>Interface</b> and fill it in with the following values:
<table class="sectionMacro" border="0" cellpadding="5" cellspacing="0" width="100%"><tbody><tr><ul>
	<li>Package: <b>sampleear</b></li>
	<li>Name: <b>RemoteBusinessInterface</b></li>
</ul>
</tr></tbody></table>
<p><br class="atl-forced-newline" /> <span class="image-wrap" style=""><img
src="/confluence/download/attachments/76337/biz_int.jpg?version=1&amp;modificationDate=1202918610000"
style="border: 0px solid black" /></span> <br class="atl-forced-newline" />
<br class="atl-forced-newline" /></p></li>
	<li>Click <b>Finish</b>.</li>
</ol>


<p>Now we need to add a business method and mark the interface as a remote one with
<b><tt>@Remote</tt></b> annotation.</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>RemoteBusinessInterface.java</b></div><div
class="codeContent panelContent">
<pre class="code-java">
<span class="code-keyword">package</span> sampleear;

<span class="code-keyword">import</span> javax.ejb.Remote;

@Remote
<span class="code-keyword">public</span> <span class="code-keyword">interface</span>
RemoteBusinessInterface {
    <span class="code-keyword">public</span> <span class="code-object">String</span>
sayHello(<span class="code-object">String</span> name);
}
</pre>
</div></div>

<h2><a name="5-minuteTutorialonEnterpriseApplicationDevelopmentwithEclipseandGeronimo-Createbeanclass"></a>Create
bean class</h2>

<ol>
	<li>Right-click on the <b>SampleEJB</b> project and select <b>New</b>
-&gt; <b>Class</b> and fill it in with the following values:
<table class="sectionMacro" border="0" cellpadding="5" cellspacing="0" width="100%"><tbody><tr><ul>
	<li>Package: <b>sampleear</b></li>
	<li>Name: <b>MyStatelessSessionBean</b></li>
	<li>Interfaces: <b>sampleear.RemoteBusinessInterface</b></li>
</ul>
</tr></tbody></table>
<p><br class="atl-forced-newline" /> <span class="image-wrap" style=""><img
src="/confluence/download/attachments/76337/bean_class.jpg?version=1&amp;modificationDate=1202919236000"
style="border: 0px solid black" /></span> <br class="atl-forced-newline" />
<br class="atl-forced-newline" /></p></li>
	<li>Click <b>Finish</b>.</li>
</ol>


<p>Implement the business method <b>sayHello</b> and mark the class as a
stateless session bean with the @Stateless annotation.</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>MyStatelessSessionBean.java</b></div><div
class="codeContent panelContent">
<pre class="code-java">
<span class="code-keyword">package</span> sampleear;

<span class="code-keyword">import</span> javax.ejb.Stateless;

@Stateless
<span class="code-keyword">public</span> class MyStatelessSessionBean <span
class="code-keyword">implements</span> RemoteBusinessInterface {

    <span class="code-keyword">public</span> <span class="code-object">String</span>
sayHello(<span class="code-object">String</span> name) {
        <span class="code-keyword">return</span> getClass().getName() + <span
class="code-quote">" says hello to "</span> + name + <span class="code-quote">"."</span>;
    }
}
</pre>
</div></div>

<h1><a name="5-minuteTutorialonEnterpriseApplicationDevelopmentwithEclipseandGeronimo-Webapplicationdevelopment"></a>Web
application development</h1>

<p>The time has come to use the ejb in the web application. In this section we create
a jsp <b><tt>index.jsp</tt></b> page that executes a servlet <b>MyServlet</b>
that in turn executes the ejb <b>MyStatelessSessionBean</b>.</p>

<h2><a name="5-minuteTutorialonEnterpriseApplicationDevelopmentwithEclipseandGeronimo-Createwelcomepageindex.jsp"></a>Create
welcome page - index.jsp</h2>

<ol>
	<li>Right-click on the <b>SampleWAR</b> project and select <b>New</b>
-&gt; <b>JSP</b>. Name it <b><tt>index.jsp</tt></b>
and click <b>Finish</b>.</li>
	<li>Change it so it executes the servlet upon form submission.
<table class="sectionMacro" border="0" cellpadding="5" cellspacing="0" width="100%"><tbody><tr>
<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>index.jsp</b></div><div
class="codeContent panelContent">
<pre class="code-html">
<span class="code-tag">&lt;%@ page language=<span class="code-quote">"java"</span>
contentType=<span class="code-quote">"text/html; charset=ISO-8859-1"</span> pageEncoding=<span
class="code-quote">"ISO-8859-1"</span>%&gt;</span>
<span class="code-tag">&lt;!DOCTYPE html PUBLIC <span class="code-quote">"-//W3C//DTD
HTML 4.01 Transitional//EN"</span> <span class="code-quote">"http://www.w3.org/TR/html4/loose.dtd"</span>&gt;</span>
<span class="code-tag">&lt;html&gt;</span>
  <span class="code-tag">&lt;head&gt;</span>
    <span class="code-tag">&lt;meta http-equiv=<span class="code-quote">"Content-Type"</span>
content=<span class="code-quote">"text/html; charset=ISO-8859-1"</span>&gt;</span>
    <span class="code-tag">&lt;title&gt;</span>5-minute Tutorial on Enterprise
Application Development with Eclipse and Geronimo<span class="code-tag">&lt;/title&gt;</span>
  <span class="code-tag">&lt;/head&gt;</span>
  <span class="code-tag">&lt;body&gt;</span>
    <span class="code-tag">&lt;form action=<span class="code-quote">"${pageContext.request.contextPath}/sayHello"</span>&gt;</span>
      <span class="code-tag">&lt;input type=<span class="code-quote">"text"</span>
name=<span class="code-quote">"name"</span> /&gt;</span><span class="code-tag">&lt;input
type=<span class="code-quote">"submit"</span> value=<span class="code-quote">"Press
me!"</span> /&gt;</span>
    <span class="code-tag">&lt;/form&gt;</span>
  <span class="code-tag">&lt;/body&gt;</span>
<span class="code-tag">&lt;/html&gt;</span>
</pre>
</div></div></tr></tbody></table></li>
</ol>


<h2><a name="5-minuteTutorialonEnterpriseApplicationDevelopmentwithEclipseandGeronimo-CreateservletMyServlet"></a>Create
servlet - MyServlet</h2>

<p>Since the servlet calls the EJB, the web project the servlet is in depends on the
EJB project. Let's define the dependency.</p>

<ol>
	<li>Right-click on the <b>SampleWAR</b> project and select <b>Properties</b>.
Go to <b>J2EE Module Dependencies</b> and select the checkbox next to <b>SampleEJB.jar</b>
(it's in the <b>J2EE Modules</b> tab) and click <b>OK</b>.
<br class="atl-forced-newline" /> <br class="atl-forced-newline" /> <span class="image-wrap"
style=""><img src="/confluence/download/attachments/76337/war_dep.1.jpg?version=1&amp;modificationDate=1202929638000"
style="border: 0px solid black" /></span> <br class="atl-forced-newline" />
<br class="atl-forced-newline" /></li>
	<li>Right-click on the <b>SampleWAR</b> project and select <b>New</b>
-&gt; <b>Servlet</b> and fill it in with the following values:
<table class="sectionMacro" border="0" cellpadding="5" cellspacing="0" width="100%"><tbody><tr><ul>
	<li>Java Package: <b>sampleear</b></li>
	<li>Class name: <b>MyServlet</b></li>
</ul>
</tr></tbody></table>
<p><br class="atl-forced-newline" /> <br class="atl-forced-newline" /> <span
class="image-wrap" style=""><img src="/confluence/download/attachments/76337/myServlet.jpg?version=1&amp;modificationDate=1202923091000"
style="border: 0px solid black" /></span> <br class="atl-forced-newline" />
<br class="atl-forced-newline" /></p></li>
	<li>Click <b>Next</b>.</li>
	<li>Change the URL Mapping section so the servlet serves at <b>/sayHello</b>
url mapping and click <b>Finish</b>.
<br class="atl-forced-newline" /> <br class="atl-forced-newline" /> <span class="image-wrap"
style=""><img src="/confluence/download/attachments/76337/url_mapping.jpg?version=1&amp;modificationDate=1202923017000"
style="border: 0px solid black" /></span> <br class="atl-forced-newline" /></li>
</ol>


<p><b>MyServlet.java</b> opens up automatically for editing after creation,
update the servlet as shown below to call off the ejb when executed.</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>MyServlet.java</b></div><div
class="codeContent panelContent">
<pre class="code-java">
<span class="code-keyword">package</span> sampleear;

<span class="code-keyword">import</span> java.io.IOException;

<span class="code-keyword">import</span> javax.ejb.EJB;
<span class="code-keyword">import</span> javax.servlet.ServletException;
<span class="code-keyword">import</span> javax.servlet.http.HttpServletRequest;
<span class="code-keyword">import</span> javax.servlet.http.HttpServletResponse;

<span class="code-keyword">public</span> class MyServlet <span class="code-keyword">extends</span>
javax.servlet.http.HttpServlet <span class="code-keyword">implements</span> javax.servlet.Servlet
{
    <span class="code-keyword">static</span> <span class="code-keyword">final</span>
<span class="code-object">long</span> serialVersionUID = 1L;

    @EJB
    RemoteBusinessInterface remoteBusinessIntf;

    <span class="code-keyword">protected</span> void doGet(HttpServletRequest
request, HttpServletResponse response) <span class="code-keyword">throws</span>
ServletException, IOException {
        <span class="code-object">String</span> name = request.getParameter(<span
class="code-quote">"name"</span>);
        <span class="code-keyword">if</span> (name == <span class="code-keyword">null</span>
|| name.length() == 0) {
            name = <span class="code-quote">"anonymous"</span>;
        }
        response.getWriter().write(remoteBusinessIntf.sayHello(name));
    }
}
</pre>
</div></div>

<h1><a name="5-minuteTutorialonEnterpriseApplicationDevelopmentwithEclipseandGeronimo-Runit%21"></a>Run
it!</h1>
<p>All it's left before we test this sample it to deploy it. This task is done automatically
for you when you choose to run the application directly from the eclipse workspace.</p>

<ol>
	<li>Right-click on the <b>SampleEAR</b> project and select <b>Run
As</b> -&gt; <b>Run on Server</b>. When <em>Run On Server</em>
popup window comes up, select the <b>Always use this server when running this project</b>
checkbox. Leave the rest as is.
<br class="atl-forced-newline" /> <br class="atl-forced-newline" /> <span class="image-wrap"
style=""><img src="/confluence/download/attachments/76337/runOnServer.jpg?version=1&amp;modificationDate=1202923460000"
style="border: 0px solid black" /></span> <br class="atl-forced-newline" />
<br class="atl-forced-newline" /></li>
	<li>Click <b>Finish</b>.</li>
	<li>The server's stopped so nothing happens (from a user's perspective at least). Open
up the <b>Servers</b> tab and right-click on <b>Apache Geronimo v2.1 Server
at localhost</b> and select <b>Start</b>.</li>
	<li>After a few seconds, Geronimo will be up and running with the enterprise application
published. Open up the browser of your choice and go to <a href="http://localhost:8080/SampleWAR"
class="external-link" rel="nofollow">http://localhost:8080/SampleWAR</a>.
<br class="atl-forced-newline" /> <br class="atl-forced-newline" /> <span class="image-wrap"
style=""><img src="/confluence/download/attachments/76337/welcome.jpg?version=1&amp;modificationDate=1202928857000"
style="border: 0px solid black" /></span> <br class="atl-forced-newline" />
<br class="atl-forced-newline" /></li>
	<li>Type in any name you want, e.g. <b><tt>John Doe</tt></b>
and press <b>Press me!</b> button.
<br class="atl-forced-newline" /> <br class="atl-forced-newline" /> <span class="image-wrap"
style=""><img src="/confluence/download/attachments/76337/result.jpg?version=1&amp;modificationDate=1202928857000"
style="border: 0px solid black" /></span> <br class="atl-forced-newline" /></li>
</ol>

    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/GMOxDOC21/5-minute+Tutorial+on+Enterprise+Application+Development+with+Eclipse+and+Geronimo">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=76337&revisedVersion=25&originalVersion=24">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/GMOxDOC21/5-minute+Tutorial+on+Enterprise+Application+Development+with+Eclipse+and+Geronimo?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message