| Sun Java System Application Server |
The general instructions for building, deploying, and running sample applications are provided in Building, Deploying, and Running Sample Applications. In reading this document, use the following application-specific variables for this application:
install_dir is the directory where Application Server is installed.
app_dir is the application base directory:
install_dir/samples/rmi-iiop/apps/simple/.
rmi-simple.ear.
asant.
install_dir/bin to your path.
cd app_dir
asant
rmi-simple.ear.
Use Admin Console or asadmin to deploy the
EAR file assembled in the previous section.
install_dir/samples/rmi-iiop/apps/simple/.
asant deploy
This deploys the application in a server instance:
domain_root_dir/domain_name/applications/j2ee-apps/rmi-simple
asadmin.
Use this command:
asadmin deploy --user username --password password --host host --port admin-port rmi-simple.earYou can also use this to verify the registration:
asadmin list-components --user username --password password
Since a pre-built enterprise archive (.ear)
file for the sample application is included with the application server,
you can use the Admin Console to quickly read in the .ear file and deploy
it to the application server.
install_dir/bin/asadmin start-domain domain1 command.
"Start > Programs > Sun Microsystems > J2EE 5
SDK > Start Default Server" command.
You can run this sample application:
The Application Client Container (ACC) is a set of Java classes, libraries and other files used to execute a first-tier application client program in its own Java VM. It communicates with the Application Server using RMI-IIOP.
To run the application using a Web browser client, follow these steps:
http://hostname:port;/rmi-iiop-simple/index.jspThe default web page will be displayed.
In this case, the Java client runs on the same machine that the Application Server is running.
Follow these steps:
cd app_dir
asadmin get-client-stubs --port 4858 --appname rmi-simpleThis step is not required if you deployed the application yourself.
install_dir/bin/appclient -client app_dir/rmi-simpleClient.jar
In this case, the Java client runs on a different machine than the one on which the Application Server is running.
cd install_dir/bin package-appclient
This creates appclient.jar
appclient.jar and rmi-simpleClient.jar files
from the Application Server machine to the remote machine.
The appclient.jar is intended to be used on a remote machine with same type
of operating system. For example, if created on a Solaris system, it
will not function on a Windows system.
applicient.jar
under a directory of your choice, acc_install_dir.
This installs ACC in acc_install_dir/appclient
acc_install_dir/appclient/config/asenv.conf
AS_INSTALL=acc_install_dir/appclient AS_WEBSERVICES_LIB=acc_install_dir/appclient/lib AS_IMQ_LIB=acc_install_dir/appclient/imq/lib AS_ACC_CONFIG=acc_install_dir/appclient/config/sun-acc.xml AS_JAVA=JDK-location
acc_install_dir/appclient/bin/appclient
Ensure the path to the environment file, asenv.conf is set to:
acc_install_dir/appclient/config/asenv.conf
acc_install_dir/appclient/config/sun-acc.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE client-container SYSTEM
"file:acc_install_dir/appclient/lib/dtds/sun-application-client-container_1_0.dtd ">
<client-container>
<target-server name="acchost" address="ashost" port="3700"/>
<client-credential user-name="j2ee" password="j2ee"/>
<log-service file="" level="WARNING"/>
</client-container>
In this example, Application Server is running on the machine with hostname
ashost
and with default ORB-port 3700, and Application
Client Container is on the machine with hostname acchost. acc_install_dir/appclient/bin
install_dir/bin/appclient -client app_dir/rmi-simpleClient.jar -xml install_dir/domain_root_dir/domain_name/config/sun-acc.xml
...... INFO: ACC014: ORB host name: [ashost] ...... INFO: ACC013: ORB port number: [3700] ......
The Java client is executed without using the interface of Application Client Container. By default it executes on the local machine. The client application runs from the command line:
java -classpath classpath ClientApp JNDIName
where classpath includes three JAR files for CLASSPATH which are
rmi-simpleClient.jar, j2ee.jar and appserv-rt.jar.
The file of rmi-simpleClient.jar is copied to the current directory
from the deployment directory,
install_dir/domains/domain_name/applications/j2ee-apps/rmi-simple.
The files j2ee.jar and appserv-rt.jar are copied to the current
directory from AS installation, install_dir/lib.
ClientApp refers to the client program. In this example, it is
samples.rmi.simple.client.ConverterClient.
JNDIName matches in the deployment file. In the example, it is rmiconverter
which can be found as <jndi-name>rmiconverter</jndi-name>
in the file
app_dir/simple/simple-ejb/src/conf/sun-ejb-jar.xml.
To run the client application on a remote machine,
transfer the rmi-simpleClient.jar, j2ee.jar and appserv-rt.jar files
to the client machine. Although the rmi-simpleClient.jar file is used
in this example to run application client with or without an ACC, it
contains more files than necessary for the situation in which an ACC is not used. The
minimal files required to run the example on a remote machine without an
ACC are the j2ee.jar and appserv-rt.jar file and the following files as
extracted from the rmi-simpleClient.jar file:
samples/rmi/simple/ejb/Converter.class: remote interface
samples/rmi/simple/ejb/ConverterHome.class: home interface
samples/rmi/simple/ejb/_Converter_Stub.class: remote stub
samples/rmi/simple/ejb/_ConverterHome_Stub.class: home stub
samples/rmi/simple/client/ConverterClient.class: client application main class
The j2ee.jar file is required on the client machine because it contains
the javax.ejb package that the client needs, and also contains the
implementation and interface for J2EE APIs that the client may need.
For example, on Solaris or Linux:
java -classpath rmi-simpleClient.jar:j2ee.jar:appserv-rt.jar samples.rmi.simple.client.ConverterClient rmiconverter
On Windows, the colons (:) are replaced by semicolons (;).
java -classpath rmi-simpleClient.jar;j2ee.jar;appserv-rt.jar samples.rmi.simple.client.ConverterClient rmiconverter
After that, you should see the last two lines from screen as the result of converting 100 units of USD to Yen, and 100 Yen to Euro.
NOTE: To run the client from a remote machine you will need to pass
org.omg.CORBA.ORBInitialHost=remote-host-name
and
org.omg.CORBA.ORBInitialPort=remote-ORB-port. For example:
java -Dorg.omg.CORBA.ORBInitialHost=hostname -Dorg.omg.CORBA.ORBInitialPort=port -classpath ./rmi-simpleClient.jar:/tmp/SUNWappserver/lib/appserv-rt.jar:/tmp/SUNWappserver/lib/j2ee.jar samples.rmi.simple.client.ConverterClient rmiconverter
Replace hostname and port with actual remote machine name and ORB port (usually 3700).
If you encounter problems when running the application, review the server log file at
domain_root_dir/domain_name/logs/server.log
Copyright © 2006 Sun Microsystems, Inc. All rights reserved.