JOnAS v2.4 Tutorial
70 pages
English

JOnAS v2.4 Tutorial

Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres
70 pages
English
Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres

Description

JOnAS v2.4 Tutorial
Emmanuel Cecchet
Rice University/INRIA
cecchet@rice.edu
Julie Marguerite
Rice University
margueri@rice.edu JOnAS v2.4 Tutorial
by Emmanuel Cecchet and Julie Marguerite
Tutorial for JOnAS v2.4 Edition
Copyright © 2002 by ObjectWeb Consortium
1This documentation is released under the JOnAS public license. Table of Contents
1. Introduction .......................................................................................................................7
How to read this document ? .....................................................................................7
Enterprise JavaBeans ...................................................................................................7
ObjectWeb and JOnAS.................................................................................................7
Who do what ?..............................................................................................................8
JOnAS features............................................................................................................10
Specifications.....................................................................................................10
JOnAS services ..................................................................................................11
JOnAS requirements ..................................................................................................11
Software requirements.................................. ...

Sujets

Informations

Publié par
Nombre de lectures 81
Langue English

Extrait

JOnAS v2.4 Tutorial
Emmanuel Cecchet Rice University/INRIA
cecchet@rice.edu
Julie Marguerite Rice University
margueri@rice.edu
JOnAS v2.4 Tutorial by Emmanuel Cecchet and Julie Marguerite
Tutorial for JOnAS v2.4 Edition Copyright © 2002 by ObjectWeb Consortium
This documentation is released under the JOnAS public license.
1
Table of Contents 1. Introduction .......................................................................................................................7 How to read this document ? .....................................................................................7 Enterprise JavaBeans ...................................................................................................7 ObjectWeb and JOnAS .................................................................................................7 Whodowhat?..............................................................................................................8 JOnAS features............................................................................................................10 Specications.....................................................................................................10 JOnAS services ..................................................................................................11 JOnASrequirements..................................................................................................11 Software requirements .....................................................................................11 Hardware requirements...................................................................................12 2. Quick Start .......................................................................................................................15 Download JOnAS .......................................................................................................15 Setting up JOnAS environment ................................................................................15 Checking that everything is correct .........................................................................16 Running your first EJB application..........................................................................16 Building the example .......................................................................................16 Running the example .......................................................................................17 3. Getting and installing the software ............................................................................19 JavaTM2 Software Development Kit .........................................................................19 Web server ...................................................................................................................19 JSP/Servlet server ......................................................................................................20 JOnAS EJB Server .......................................................................................................20 Getting and installing the binary distribution .............................................20 Getting the source distribution .......................................................................21 Using the CVS repository ................................................................................21 Apache Ant .................................................................................................................22 4. Configuring your environment ....................................................................................25 Setting up your Java environment ...........................................................................25 Configuring Apache ..................................................................................................26 Setting up your httpd.conf ..............................................................................26 Specifying a remote or multiple Tomcat servers ..........................................26 ConguringTomcat...................................................................................................27 Environment variables setting ........................................................................27 Starting Tomcat with JOnAS/RMI .................................................................28 Starting Tomcat with JOnAS/Jeremie ...........................................................28 Large number of servlets in Tomcat...............................................................28 Configuring Ant .........................................................................................................29 Configuring JOnAS ....................................................................................................30 Compiling the source distribution .................................................................30 Setting your environment................................................................................31 5. Getting started with JOnAS..........................................................................................35 Overview of the tools.................................................................................................35 Starting and stopping JOnAS ...................................................................................35 JOnAS configuration files..........................................................................................36 jonas.properties.................................................................................................36 jndi.properties ...................................................................................................38 Database access .................................................................................................39 Loading and unloading Beans..................................................................................39 Loading beans using jonas.properties ...........................................................40 Loading beans using JonasAdmin .................................................................40 Unloading beans ...............................................................................................40 JOnAS administration ...............................................................................................41
5
6
Running multiple JOnAS servers.............................................................................41 Autonomous servers ........................................................................................41 Distributing the beans over several servers..................................................41 6. Session Beans ..................................................................................................................45 Finding the example application .............................................................................45 Buildingtheexample.................................................................................................45 Running the example.................................................................................................45 Understanding Session Beans ..................................................................................46 The deployment descriptor.......................................................................................47 Troubleshooting..........................................................................................................47 7. Entity Beans .....................................................................................................................49 Finding the example application .............................................................................49 Buildingtheexample.................................................................................................49 Configuring the database access ..............................................................................49 Defining a datasource ......................................................................................49 Creating the database.......................................................................................50 Running the example.................................................................................................51 Understanding Entity Beans.....................................................................................52 The deployment descriptor.......................................................................................52 Troubleshooting..........................................................................................................54 8. Message-Driven Beans ..................................................................................................55 Building the examples ...............................................................................................55 Running the examples ...............................................................................................55 Understanding Message-Driven Beans...................................................................55 The deployment descriptor.......................................................................................55 Troubleshooting..........................................................................................................55 9. Accessing beans from a Servlet....................................................................................57 Quick introduction to Servlets .................................................................................57 Retrieving a home interface and creating a bean ..................................................57 Initiating a transaction from a Servlet .....................................................................58 10. Accessing beans from a JSP ........................................................................................61 Quick introduction to JSP..........................................................................................61 Accessing a bean from a JSP .....................................................................................61 11.TheAlarmapplication.................................................................................................63 Application architecture overview ..........................................................................63 Finding the alarm application ..................................................................................64 Setting up the application .........................................................................................64 ConguringTomcat(more)......................................................................................65 Configuring the database access ..............................................................................65 Running the alarm demo ..........................................................................................65 Known bugs or limitations .......................................................................................66 12. Support ...........................................................................................................................67 Documentation ...........................................................................................................67 Release documentation ....................................................................................67 Other documentation .......................................................................................67 Mailinglists.................................................................................................................68 JOnAS users mailing list ..................................................................................68 JOnAS team mailing list ..................................................................................68 Extensive technical support ......................................................................................68
Chapter 1. Introduction The purpose of this tutorial is to explain how to install and configure the JOnAS EJB server. Then it guides the user for running any kind of JavaBeans in JOnAS using the examples provided in the distribution.
How to read this document ? You are currently reading the introduction that gives an overview of the JOnAS world. For the impatients who want to start playing with JOnAS without going through the details of all steps, you can try the next chapter (Chapter 2). Note that this Quick Start requires some skills like downloading and uncompressing an archive or setting environment variables. For those who are not familiar with those tasks, you should better read sequentially the tutorial from Chapter 3 that details every single step. Chapter 3 and Chapter 4 help you setting up all the software needed for a complete J2EE environment including Web, Servlets and EJB servers. This part also describes how to configure the software for a distributed environment (servers running on separate physical machines). Chapter 5 is a quick reference to JOnAS and guides you through the most common tasks you will have to perform. The remaining chapters are specific to EJB applications development. Each chapter treats a different programming concept and illustrates it with a specific example. The Alarm application is a “put it all together” example that gives an overview of a complete application using JOnAS.
Enterprise JavaBeans The SunTMEnterprise JavaBeans specification1defines an architecture and interfaces for developing and deploying distributed JavaTMserver applications based on a multi-tier architecture. This specification intends to facilitate and normalize the development, deployment and assembling of applicative components (called enterprise beans); such compo-nents will be deployable on EJB platforms. The resulting applications are typically transactional, database-oriented, multi-user, secured, scalable and portable. More pre-cisely, this EJB specification describes two kinds of information: The first one is the runtime environment, called EJB server, which provides the exe-cution environment together with the transactional service, the distribution mech-anisms, the persistence management and the security. The second one is some kind of programmer’s guide and user’s guide explaining how an enterprise bean should be developed, deployed and used. Not only will an enterprise bean be independent of the platform and operating sys-tem (since written in Java), but also of the EJB platform.
ObjectWeb and JOnAS ObjectWebis an open source software community created at the end of 1999 by France Télécom R&D2, Bull/Evidian3and INRIA4. Its goal is to develop innovative middle-ware components available under an open source licence. These components can be
7
Chapter 1. Introduction
used to build distributed platforms that can be apdated to specific application re-quirements. JOnAS is one of the ObjectWeb projects but interact with other projects. To let you have an overview of JOnAS’s integration in ObjectWeb, here is a the list of the projects currently hosted by ObjectWeb: JOnAS5 JOnAS (JavaTMApplication Server) is a distributed platform compliant with theOpen EJBTMspecifications. JOnAS provides object distibution, security, distributed trans-apcrtoiovindseasnJdMoSTbject persistency support according to these specifications. JOnAS also M(Java Message Service) and JCATM(Java Connector Architecture) sup-port through its integration with JORAM and JORM. Jonathan6 Jonathan is an adaptable distributed object platform, which currently provides sev-eraoltpheerrsoonnealiwtiietsh,itnhceluRdMinITgMceiacitnoasdniththeOMGCORBAspoocenilpmwtnanoitaci an spec . The RMI personality, called Jeremie, can be used in JOnAS to replace the standard RMI and optimize local calls. JORAM7 in im-JplOeRmAenMta(tJiaovnaoTfMtehMJSROpenTeMagssereScevipe)scicoitaOJ.npMAR(aJaveMgasseMsuonorhcceursoenopanisg)desroviAsynableli a MOM (Message Oriented Middleware) built on top of the ScalAgent8distributed agent technology. JORM9 JORM (JavaTMObject Repository Mapping) is an adaptable persistence service of-fering various personalities, inclTuMhtiwtnaiJEPMCehtngdiapDlaovmeacOaotnion.BJORTMpeciMsprovicdae-s tion and another with the JDO (J bjects) specificat object persistency through different secondary storage supports, such as file, rela-tional d or ob e f the JCATaMvaCo(JaotArnnceettccrihecspe)uronticai.sjtctbasaseddatabas-orienteulcnasedJ.seiMROatntnoiompnimele OpenCCM10 OpenCCM (Open CORBA Component Model platform) is the first public available tohpeenOsMouGr11eimpcntatlemetfehoionOCBRCC(MnepoomACl)deMontybdened(ObjectManagemenGtorpu.)pOneCCaMowllodstigesimn,melp,tne compile, package, deploy and execute distributed applications compliant with the OMG’s CORBA Component Model. It includes a complete OMG IDL3 compiler, an OMG IDL3 Repository, generators for CCM’s OMG IDL2 mapping and extended Java component skeletons, a Java component server to host Java components, and a distributed deployment infrastucture. RmiJdbc12 RmiJdbc is a remote JDBCTMdriver which, in conjuction with a local JDBC driver, allows remote access to a relational database through RMITM.
Who do what ? The JavaTM2 Enterprise Edition (J2EE) platform is a n-tier platform. Each tier has a specific role that we try to define hereafter:
8
Chapter 1. Introduction
Clients Clients are the end-users of the system and can access the EJB server by several means. One of the most common is to use a Web browser like Netscape or Inter-net Explorer and connect to a Web server where Java Servlets or Java Server Pages (JSP) access the business logic of the EJB server (see Figure 1-2). Another solution, is to use a specific Java programs that directly communicates with the EJB server (see Figure 1-1). Web server The Web server is responsible for accepting client requests and sending HTML replies back. HTML pages can be static files that resides on the Web server filesystem or dynamically built with Servlets or JSP from data generated by the beans. Servlet/JSP server The Java Server Page (JSP) server or Servlet container can be integrated in the Web server or be a separate entity communicating with the Web server. JSP or servlets run within a Java Virtual Machine that can eventually be the same as the one used by the EJB server. This last case is not supported in JOnAS version 2.4. EJB server The EJB server is the place where the beans are executed. JOnAS is fully implemented in Java and all the beans loaded in an instance of JOnAS run within the same Java Vir-tual Machine. It is possible to run several different JOnAS EJB servers on the same or separate machines (see the section calledRunning multiple JOnAS serversin Chapter 5). Database server The database server is used to store and retrieve the data. It is accessed thro he standard JDBCTM ughAPI by the beans. t
Figure 1-1. Accessing EJB server business logic from a Java client
9
Chapter 1. Introduction
Figure 1-2. J2EE n-tier architecture overview The distributed environment in the EJB world is RMI but JOnAS supports several distributed processing environments:
RMI using the SunTMproprietary protocol JRMP Jeremie: the RMI personality of an Object Request Broker called Jonathan13, that also provides a CORBA personality. Jeremie allows JOnAS to benefit from local RMI calls optimization. RMI/IIOP: this interoperability with the CORBA world is currently in experimen-tal phase. Full support of RMI/IIOP will be provided in version 2.5.
JOnAS features JOnAS implements a set of specifications of the J2EE platform. We briefly list the specifications JOnAS version 2.4 complies to. You will also find a quick description of the services provided by JOnAS.
Specications JOnAS provides full support of the following specifications:
10
Enterprise JavaBeans containers are provided by a set of Java classes and aEJB 1.1: tool to generate interposition classes JTA 1.0 114: a Transaction Manager provides Java Transaction API support and dis-. tributed transaction coordination JDBC 2.015: a Database Manager providing Java DataBase Connectivity support JMS 2.0.16117: Java Messaging Service is provided by JORAM, a technology from ScalAgent JMX18: JOnAS contains the Java Management Extension technology. Management and monitoring is available through a Web interface JCA 1.019: JOnAS supports the J2EE Connector Architecture that defines a set of mechanism that enable the integration of Enterprise Information Systems (EIS) Security management
Chapter 1. Introduction
JOnAS also provides partial support of the EJB 2.0 specification with Message-Driven Beans. Support of EJB 2.0 will increase in the next releases.
JOnAS services JOnAS offers several services that can be turned on or off according to your needs. We briefly define the set of services JOnAS provides: ejb: this is the EJB container service. This service is usually mandatory, it can only be disabled if you want to run a standalone jtm service (jtm without any other services). the distributed Transaction Manager. This service is mandatory even ifjtm: this is you use a single jtm for several JOnAS server, every server must start the jtm server (for more information about running multiple JOnAS servers, see the section called Running multiple JOnAS serversin Chapter 5) dbm: the DataBase Manager provides database access through JDBC. You must turn it on if you want to access a database from your beans (bean or container managed persistence). jms: the Java Messaging Service must be started if you use message-driven beans. Note that the jms must be started before the ejb service. security: this is the security service. and monitor JOnAS through a Web interfacejmx: this service allows to manage using JAdmin. Note that if you want to use jmx, it must be the first service to be started. resource: the resource service is an optional service that must be started as soon as EJB components have to access an external Enterprise Information System. Yhe standard way of doing this is to use a third party software component called Re-source Adapter.
How to configure and start those different services is described in the section called JOnAS configuration filesin Chapter 5.
JOnAS requirements In order to run JOnAS, you need some additional software that are not provided in the JOnAS distribution. You may also wonder what kind of hardware configuration do I need to run all that stuff ! There is not a single answer to these questions but many, according to your needs. However, we will try to provide some useful infor-mation to help you make your mind.
Software requirements Here is a list of the main software components you may need in order to run JOnAS:
a JavaTM2 Software Development Kit (SDK) version 1.2 or higher. A SDK version 1.3 is recommended but if you want to stick to your old SDK it is fine as long as it is compliant with the 1.2 specification. JOnAS also works with the current release
11
  • Univers Univers
  • Ebooks Ebooks
  • Livres audio Livres audio
  • Presse Presse
  • Podcasts Podcasts
  • BD BD
  • Documents Documents