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 > Deploy and Run a Java EE Application Client
Date Mon, 07 Mar 2011 16:01:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2036/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/Deploy+and+Run+a+Java+EE+Application+Client">Deploy
and Run a Java EE Application Client</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~kevan">Kevan
Miller</a>
    </h4>
        <br/>
                         <h4>Changes (7)</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" >    &lt;dep:client-environment&gt;
<br>        &lt;dep:moduleId&gt; <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-changed-words">&lt;dep:groupId&gt;J<span
class="diff-added-chars"style="background-color: #dfd;">ava</span>EE5&lt;/dep:groupId&gt;</span>
<br></td></tr>
            <tr><td class="diff-unchanged" >            &lt;dep:artifactId&gt;EXAMPLEClient&lt;/dep:artifactId&gt;
<br>            &lt;dep:version&gt;2.1&lt;/dep:version&gt; <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >    &lt;dep:server-environment&gt;
<br>        &lt;dep:moduleId&gt; <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-changed-words">&lt;dep:groupId&gt;J<span
class="diff-added-chars"style="background-color: #dfd;">ava</span>EE5&lt;/dep:groupId&gt;</span>
<br></td></tr>
            <tr><td class="diff-unchanged" >	    &lt;dep:artifactId&gt;EXAMPLEClientServer&lt;/dep:artifactId&gt;
<br>	    &lt;dep:version&gt;2.1&lt;/dep:version&gt; <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{noformat:borderStyle=solid} <br>jar
cfM  app_client.jar -C D:\workspace2\GERONIMO_APPLICATION\bin . <br></td></tr>
            <tr><td class="diff-changed-lines" >java -jar %GERONIMO_HOME%/bin/deployer.jar
--user system --password manager --host localhost undeploy <span class="diff-changed-words">J<span
class="diff-added-chars"style="background-color: #dfd;">ava</span>EE5/EXAMPLEClient/2.1/car</span>
<br></td></tr>
            <tr><td class="diff-changed-lines" >java -jar %GERONIMO_HOME%/bin/deployer.jar
--user system --password manager --host localhost undeploy <span class="diff-changed-words">J<span
class="diff-added-chars"style="background-color: #dfd;">ava</span>EE5/EXAMPLEClientServer/2.1/car</span>
<br></td></tr>
            <tr><td class="diff-unchanged" >java -jar %GERONIMO_HOME%/bin/deployer.jar
--user system --password manager deploy app_client.jar <br>pause <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" > <br>{noformat:borderStyle=solid}
<br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-changed-words">J<span
class="diff-added-chars"style="background-color: #dfd;">ava</span>EE5/EXAMPLEClient/2.1/car</span>
   	   state: stopped <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-changed-words">J<span
class="diff-added-chars"style="background-color: #dfd;">ava</span>EE5/EXAMPLEClientServer/2.1/car</span>
  state: running <br></td></tr>
            <tr><td class="diff-unchanged" >{noformat} <br> <br>You
can run the Application Client with this command: <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >*{{%GERONIMO_HOME%/bin/client
<span class="diff-changed-words">J<span class="diff-added-chars"style="background-color:
#dfd;">ava</span>EE5/EXAMPLEClient/2.1/car}}*</span> <br></td></tr>
            <tr><td class="diff-unchanged" > <br>You should notice the application
client message in the Geronimo console.  <br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <p>You can create an application client that runs in the Apache Geronimo application
client container rather than running in your local Java environment. The main purpose of the
Geronimo client application container is to provide a standard set of services to a client
program without forcing the client application to specify a list of dependencies - in other
words ease-of-development. The client code can lookup Geronimo components such as resources,
EJBs, and connectors via standard JNDI lookup. This example creates the simplest application
client that can talk to a Geronimo server and place a message in the Geronimo console.</p>

<p>Create a client jar file for a simple example with these files. The client will write
a message "CLIENT RUNNING..." on the Geronimo console:</p>

<p>1. - client/MainClient.java</p>

<div class="code panel" style="border-style: solid;border-width: 1px;"><div class="codeContent
panelContent">
<pre class="code-java">
<span class="code-keyword">package</span> client;

<span class="code-keyword">public</span> class MainClient {

    /**
     * @param args ignored
     */
    <span class="code-keyword">public</span> <span class="code-keyword">static</span>
void main(<span class="code-object">String</span>[] args){
        <span class="code-object">System</span>.out.println (<span class="code-quote">"CLIENT
RUNNING..."</span>);  
    }
}
</pre>
</div></div>

<p>Create an application client deployment descriptor that provides the client display
name:</p>

<p>2. - META-INF/application-client.xml</p>

<div class="code panel" style="border-style: solid;border-width: 1px;"><div class="codeContent
panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;?xml version=<span class="code-quote">"1.0"</span>?&gt;</span>
&lt;application-client xmlns=<span class="code-quote">"http://java.sun.com/xml/ns/j2ee"</span>
<span class="code-keyword">xmlns:xsi</span>=<span class="code-quote">"http://www.w3.org/2001/XMLSchema-instance"</span>
 xsi:schemaLocation=<span class="code-quote">"http://java.sun.com/xml/ns/j2ee [http://java.sun.com/xml/ns/j2ee/applicationclient_1_4.xsd]"</span>
version=<span class="code-quote">"1.4"</span>&gt;
    <span class="code-tag">&lt;display-name&gt;</span>EXAMPLE Client<span
class="code-tag">&lt;/display-name&gt;</span>
<span class="code-tag">&lt;/application-client&gt;</span>
</pre>
</div></div>

<p>Create a Geronimo application client deployment plan that describes the deployment
moduleId and types. You need to define two modules, one for client side and one for server
side. EXAMPLEClientServer is the component that always its going to be running on the server,
and  EXAMPLEClient is the component that you are going to run on the client from client.jar.</p>

<p>3. - META-INF/geronimo-application-client.xml</p>

<div class="code panel" style="border-style: solid;border-width: 1px;"><div class="codeContent
panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;?xml version=<span class="code-quote">"1.0"</span>?&gt;</span>
<span class="code-tag">&lt;application-client xmlns=<span class="code-quote">"http://geronimo.apache.org/xml/ns/j2ee/application-client-2.0"</span>
<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:client-environment&gt;</span>
        <span class="code-tag">&lt;dep:moduleId&gt;</span>
            <span class="code-tag">&lt;dep:groupId&gt;</span>JavaEE5<span
class="code-tag">&lt;/dep:groupId&gt;</span>
            <span class="code-tag">&lt;dep:artifactId&gt;</span>EXAMPLEClient<span
class="code-tag">&lt;/dep:artifactId&gt;</span>
            <span class="code-tag">&lt;dep:version&gt;</span>2.1<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:client-environment&gt;</span>

    <span class="code-tag">&lt;dep:server-environment&gt;</span>
        <span class="code-tag">&lt;dep:moduleId&gt;</span>
            <span class="code-tag">&lt;dep:groupId&gt;</span>JavaEE5<span
class="code-tag">&lt;/dep:groupId&gt;</span>
	    <span class="code-tag">&lt;dep:artifactId&gt;</span>EXAMPLEClientServer<span
class="code-tag">&lt;/dep:artifactId&gt;</span>
	    <span class="code-tag">&lt;dep:version&gt;</span>2.1<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:server-environment&gt;</span>
    
<span class="code-tag">&lt;/application-client&gt;</span>
</pre>
</div></div>

<p>Create a manifest that tells the Java jar util which class to run first.</p>

<p>4. - META-INF/MANIFEST.MF</p>

<div class="preformatted panel" style="border-style: solid;border-width: 1px;"><div
class="preformattedContent panelContent">
<pre>Manifest-Version: 1.0
Main-Class: client.MainClient
\# blank line
</pre>
</div></div>

<p><tt>MANIFEST</tt> <b>must</b> contain the Main-Class and
blank line at the end of the file.</p>

<p>Create a bat file that packages the client jar, undeploys any older versions of the
client/server apps, and deploys the client application. This bat file creates the J2EE application
client jar file (Here is is named app_client.jar.) and associated files from an application
bin folder (in this case D:\workspace2\GERONIMO_APPLICATION\bin). Run java client/MainClient.java
to create a class file. The jar command -M paramenter indicates the jar file must be created
using a MANIFEST.MF file. Verify that this is correct after create jar file.</p>

<div class="preformatted panel" style="border-style: solid;border-width: 1px;"><div
class="preformattedContent panelContent">
<pre>jar cfM  app_client.jar -C D:\workspace2\GERONIMO_APPLICATION\bin .
java -jar %GERONIMO_HOME%/bin/deployer.jar --user system --password manager --host localhost
undeploy JavaEE5/EXAMPLEClient/2.1/car
java -jar %GERONIMO_HOME%/bin/deployer.jar --user system --password manager --host localhost
undeploy JavaEE5/EXAMPLEClientServer/2.1/car
java -jar %GERONIMO_HOME%/bin/deployer.jar --user system --password manager deploy app_client.jar
pause
</pre>
</div></div>

<p>After deploy, you will see the two components into Geronimo Web Console -&gt;
Applications -&gt; App Clients:</p>

<div class="preformatted panel" style="border-style: solid;border-width: 1px;"><div
class="preformattedContent panelContent">
<pre>JavaEE5/EXAMPLEClient/2.1/car    	   state: stopped
JavaEE5/EXAMPLEClientServer/2.1/car   state: running
</pre>
</div></div>

<p>You can run the Application Client with this command:</p>

<p><b><tt>%GERONIMO_HOME%/bin/client JavaEE5/EXAMPLEClient/2.1/car</tt></b></p>

<p>You should notice the application client message in the Geronimo console. </p>
    </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/Deploy+and+Run+a+Java+EE+Application+Client">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=70444&revisedVersion=8&originalVersion=7">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/GMOxDOC21/Deploy+and+Run+a+Java+EE+Application+Client?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message