J2EE Application Development B.Ramamurthy 08/08/23 1

12 Slides73.50 KB

J2EE Application Development B.Ramamurthy 08/08/23 1

Introduction We will show how to develop, deploy and run a simple clientserver application that consists of a currency converter enterprise bean and two clients: a J2EE client and a web client that consists of a JSP page. 08/08/23 2

The Setup Source code from http://java.sun.com/j2ee/download.html#tutorial Get the J2EE1.3 from http://java.sun.com/j2ee Get the “ant” build tool from Jakarta. This is similar to “make” utility of unix. Setup the environment variables: 08/08/23 JAVA HOME: location of J2SE installation J2EE HOME: location of J2EE installation ANT HOME: location of ant installation PATH : include “bin” directories of J2EE, J2SE and ant installation 3

Starting the Server J2EE server is a web server, servlet server and also an application server. You start it by j2ee –verbose You stop the server by J2ee -stop 08/08/23 4

Deployment Has two modes: command line and GUI interface. In the case of GUI tool you create an “ear” file and the drop the component modules into this “ear” (enterprise archive) file. In the case of command line you will make the components first and then assemble them into an “ear” file. To start a deploy tool deploytool 08/08/23 5

Application source code An enterprise bean which represents the business logic of an application: Remote interface: defines the business methods that a client may call. Home interface: defines the methods to create, find or remove an enterprise bean. Enterprise bean class: implements the two interfaces and also callbacks for containers. Our application is called “converter”. Lets study the code representing these files. 08/08/23 6

Compiling the Source code The compile targets for this tutorial are available in a file build.xml. You compile the “converter” java files by ant converter 08/08/23 7

Packaging For this example, “ear” file will be: ConverterApp.ear This file will contain: EJB JAR file, Web client’s WAR file and Application clients JAR file/class file Deploytool helps in configuring and packaging each component. It automatically creates the deployment descriptor. 08/08/23 8

Packaging the enterprise bean Add the classes that make the bean component: Converter.class, ConverterBean.class, ConverterHome.class to the “jar” Specify properties: bean type (session, entity, etc.), transactions etc. The deploytool has various tabs and support to specify these. 08/08/23 9

Application Client Written in Java. Can run on any Java runtime (need not be J2EE). In this application client requires two JAR files: JAR file for the J2EE containing client’s deployment descriptor and its class files, and the second JAR files containing stub classes required at run time by the client. 08/08/23 10

Application Client (contd.) and Web Client Basic tasks performed by the client of an enterprise bean: Locating the home interface Creating an enterprise bean instance Invoking a business method Deploytool: Creates client’s deployment descriptor Puts deployment descriptor and client code into a JAR file Add the JAR file to the applications ConverterApp.ear file We use JSP for this purpose: contains the same tasks as the application client plus web display elements. 08/08/23 11

Deployment and Running the Clients JNDI: We also specify JNDI names using the deploytool. Tools deploy of the tool. http://java.sun.com/j2ee/tutorial/1 3-fcs/doc/Tools10.html runclient etc. to run from command line Webclient: http:// host :8000/converter 08/08/23 12

Back to top button