The simpleStateless example demonstrates how to create and access a simple session bean with Lutris EAS. It is a good starting point to build more advanced EJB applications to run under the Lutris EAS Application Server.
It is assumed that you have installed Sun's JDK v1.3.1 and Lutris EAS 4.0.1 and the Lutris Management Console (optional)
In this document, items enclosed in <> brackets are path names that should be expanded to their full paths when entering them into the command line. For example, if EAS is installed to C:\EAS4\lutris-eas4 the cd <eas_root>\bin would be entered as CD C:\EAS4\lutris-eas4\bin
In this document when the only difference to a location is slash orientation, Windows uses a \ and UNIX uses a / the UNIX notation may be the only one displayed and the Windows user may have to make the slash orientation conversion.
If you haven't already set up your environment, do one of the following:
UNIX:
. <eas_root>/setup.bash
source <eas_root>/setup.bash
Windows:<eas_root>\setup.bat (Note: it is important to include the '.bat' as part of the command)
From the command prompt change to the directory where the jar is located and enter:
jar xf simplestateless.jar
Use the 'ant' tool to build the application:
UNIX:
cd <sample_dir>/simpleStateless/bin
ant
Windows:cd <sample_dir>\simpleStateless\bin
ant
The 'ant' command will activate the build process using <sample_dir>/simpleStateless/build.xml as its control file.
The application will be compiled, with the resulting class files put in the classes directory. Then an EAR file will be created:
<sample_dir>/simpleStateless/output/archive/simpleStateless.ear
The simpleStateless example can be deployed to Lutris EAS using the command line, the hot deploy directory or through the Lutris Management Console. Next it can be tested using a thin-client web browser. Finally it can be undeployed via the command line or though the Lutris management Console.
1. Start Lutris EAS
UNIX:
cd <eas_root>/bin
multiserver
Windows:cd <eas_root>\bin
multiserver.bat
2. Deploy the application via the command line
(Note: as an alternative to the command line, deployment can be done through
a copy to a deploy directory. See 2.5 below)
Enter the following into a second command line window.
UNIX:
cd <sample_dir>/simpleStateless/output/archive/
deploy simpleStateless.ear
Windows:cd <sample_dir>\simpleStateless\output\archive\
deploy simpleStateless.ear
2.5 Deploy the application through the "Hot Deploy" directory via
a copy command
(Note: as an alternative to the directory method, deployment can be done thorough
a deploy command. See 2. above)
UNIX:
cp <sample_dir>/simpleStateless/output/archive/simpleStateless.ear> <eas_root>/deploy
Windows:copy <sample_dir>\simpleStateless\archive\simpleStateless.ear <eas_root\deploy
3. Test the application
Activate a browser and navigate to http://localhost:8002/examples/SimpleStateless/
Notice that the line that reads: "At the tone, the non-standard time will be: HH:MM:SS" has a random capitalization pattern.
The capitalization randomization is performed in the simple session EJB.
Click the "Sample redirect back to here." link and notice that the capitalization pattern changes demonstrating that the EJB is called each time the page is reloaded.
4. Undeploy the application via the command line
UNIX:
cd <sample_dir>/simpleStateless/output/archive/
undeploy simpleStateless
Windows:cd <sample_dir>\simpleStateless\output\archive\
undeploy simpleStateless
(Notice the absence of the .ear extension used for the deployment.)
5. Shut down the EAS application server
Reactivate the command line that is running the EAS server. In a Windows or XWindows environment, click on the command window running the application server.
Press the CNTL-C keys and answer y to the terminate batch job prompt.
1. Launch the Lutris Management Console:
UNIX:
\bin\console
Windows:Start | Programs | Lutris Management Console | Management Console
2. Start the Lutris EAS server from within the Lutris Management Console:
Menu | Server | Start Local Server
Enter the installation directory of the Lutris EAS installation.
Click the 'Start' button
Wait for the Status History to display "All services loaded. Lutris EAS is up."
3. Connect to the EAS server from the Lutris Management Console:
Menu | Server | Connect
Click on 'localhost:1099' and then the 'Connect' button
Enter Username = "admin" Password = "enhydra"
Click the 'Connect' button
Wait for the Status History to stop giving new loading messages and then click the 'Dismiss' button
4. Deploy the application from the Lutris management console:
Click 'Deployer' Tab
Click 'localhost:1099'
Click the Deploy Icon (The one with the green plus sign)
Navigate to the/simpleStateless/output/archive/
Click on simpleStateless.ear
Click the 'Ok' button
The Status History will display "Deployment successful: simpleStateless.ear"
5. Test the application
Activate a web browser and navigate to http://localhost:8002/examples/SimpleStateless/
Notice that the line that reads: "At the tone, the non-standard time will be: HH:MM:SS" has a random capitalization pattern.
The capitalization randomization is performed in the simple session EJB.
Click the "Sample redirect back to here." link and notice that the capitalization pattern changes demonstrating that the EJB is called each time the page is reloaded.
6. Undeploy the application from the Lutris management console:
In the management console, click the "Deployer" Tab
Expand "localhost:1099" by double clicking on it until its deployments show
Double click on the "Enterprise Applications" until the "simpleStateless" deployment shows
Click the "simpleStateless" deployment to select it
Click the undeploy icon (The one with the red minus sign)
Click the "Yes" button in reply to the "Do you really want to undeploy" question box
The Status History will display "Undeployment successful: Local/facility=SimpleStateless_App"
5. Shut down the Lutris management console
Menu | File | Exit and then click the Yes button in the "Are you sure you want to exit the Lutris Management Console" dialog box.
This section describes the files that are used in the simpleStateless example.
/simpleStateless/build.xml
ANT build file that builds the application. ANT is a Java based build tool similar to make. Its users manual is available at http://jakarta.apache.org/ant/manual/index.html
/simpleStateless/simpleStateless.htm
Readme document that explains how to unjar, build, deploy, test, and undeploy the simpleStateless example. (This file)
/simpleStateless/input/java.policy.in
Security policy file that controls access.
/simpleStateless/src/business/SimpleStateless.java
The remote interface for EJB access. Used to create the remote object used by both the container and the client code for EJB access. Contains EJB method definitions with matching bodies in the EJB code. After EJB instantiation when the client calls the bean methods, they are intercepted by the container and passed to the Actual bean code.
/simpleStateless/src/business/SimpleStatelessBean.java
The actual bean methods that are called from the client through the container by way of the EJB object. Also contains the constructor, ejbCreate(…), called through the Home Object directly after it has done an object factory instantiation of the EJB object.
/simpleStateless/src/business/SimpleStatelessHome.java
Contains the home interface class factory that is responsible for creating, destroying, and finding EJB objects. There is a one to one correspondence between the EJB constructor declarations create(…) in the Home interface and their definitions in the bean ejbCreate(…) methods.
/simpleStateless/src/business/META-INF/ejb-jar.xml
EJB 1.1 deployment descriptor file from Sun. Defines the EJBs. For example defines an EJB as a Stateless type. Uses \lutris-eas4\dtds\ejb-jar_1_1.dtd
/simpleStateless/src/business/META-INF/jonas-ejb-jar.xml
Lutris EAS specific Deployment Descriptor defines services the EJB container provides to the EJB component. For example, it defines the nickname used for JNDI lookup to support location transparency of the EJB. Uses \lutris-eas4\dtds\jonas-ejb-jar_1_1.dtd
/simpleStateless/src/META-INF/application.xml
Lutris EAS Application Descriptor file required to deploy Enterprise applications (EAR). It defines the modules, security-role, description and icon. Uses /lutris-eas4/dtds/application_1_2.dtd
/simpleStateless/src/presentation/Enhydra.gif
Drawing of a Sea Otter.
/simpleStateless/src/presentation/index.jsp
Java Server Page (JSP) used to map a URL to a Servlet
/simpleStateless/src/presentation/options.xmlc
Maps the URL to be redirected by the index.jsp
/simpleStateless/src/presentation/RedirectServlet.java
Contains the code for the redirection called by the index.jsp
/simpleStateless/src/presentation/Welcome.html
HTML file that contains the static fields and id tags that the XML compiler (XMLC) uses to create the W3C Document Object Module that the java code accesses in the presentation layer to replace the static text with real data.
/simpleStateless/src/presentation/WelcomeServlet.java
Servlet code that uses JNDI to get the location of the EJB, instantiates the Home Object, used the Home object to instantiate the EJB object, and then accesses the EJB object through the container via the remote interface. Uses the data from the EJB to update the presentation via the W3C DOM with the new information. The DOM is then translated back to .html by XMLC and output to the client browser for rendering.
/simpleStateless/src/presentation/WEB-INF/enhydra-web.xml
Lutris EAS specific Web descriptor file. Used to allow the web container to access EJBs, J2EE resources, and classes. For example, allows the Servlet to access the EJB by giving its nickname and JNDI reference to its home class factory interface. Uses
< eas_root>/lutris-eas4/dtds/enhydra-web_1_0.dtd
/simpleStateless/src/presentation/WEB-INF/web.xml
Sun standard deployment descriptor for web applications. Identifies the Servlets contained within the WAR file. Uses
<eas_root> /lutris-eas4/dtds/web-app_2_2.dtd
Copyright © 2001 by Lutris Technologies Inc. All rights reserved.