...
Anchor
Enterprise Java Beans has been one of the corner stones of the J2EE specification. As a J2EE 1.5 certified application server, Apache Geronimo supports EJB's extensively with the help of OpenEJB EJB Container. Although it is possible to use standard Java objects to contain your business logic and business data, using EJBs addresses many of the issues of using simple Java objects, such as scalability, lifecycle management and state management. In this article, you will see how an initial database application is extended and used for both local and remotely referred application clients for an Enterprise Java Beans back end. The application uses the built-in Apache Derby as its database. Use this article to learn how to simplify your enterprise application development process.
...
- Overview of EJB Features
- Application Overview
- Configuring, Building and Deploying the Sample Application
- Testing of the Sample Application
- Summary
Overview of EJB Features Anchor overview overview
EJB implementation may vary from one vendor to another.The following are the main list of features Apache Geronimo supports as a J2EE container.
- Stateful and stateless Session Beans
- Entity Beans
- Message driven beans (MDBs)
- Interoperability using RMI-IIOP or JAXRPC
- Ability to expose stateless session beans and MDBs as Web Services
- Support for sending and receiving messages via Web Services
- Easy provisioning and hot deployment of EJB and JMX-based Web Services
- Access to EJBs from external CORBA objects
Application Overview Anchor application application
As mentioned above the Banking application supports two types of business application clients.The overview of each client is given below.
...
Finally, the banking application will be deployed as an EAR to the application server. The overview of the structural content of the EAR file is given in the following example.
...
...
First, we will look at how the business service layer of the application has been implemented with the help of EJBs.
Corresponding openejb-jar.xml defines Geronimo specific features of EJBs. Since we will deploy the database pool along with the application, there is no need to provide a dependency to an existing database pool.
...
...
persistence.xml defines a persistence unit which is used by an EntityManagerFactory in order to talk to BankDB through the BankPool configuration. The name that is given to this <persistent-unit> will be used when trying to reference it via an annotation in the EJB. By setting the SynchronizeMappings property it will not overwrite what is already in the database. So this is important to have when you do not want your data to be deleted. The jta-data-source and non-jta-data-source should point to the same thing.
...
...
web.xml does not do anything special here. It just enumerates the servlets present in the web-app and maps the url-pattern for each of them.
...
...
geronimo-web.xml is the Geronimo specific deployment plan. As usual, it specifies the module's information and context-root. So in order to visit the web-app the root url will be http://localhost:8080/Bank.
...
...
BankPool.xml provides the connection information for a database on Geronimo. In this case we are using Geronimo's built-in Derby database. The dependency for it should actually be org.apache.geronimo.configs/system-database//car. It has caused me problems when trying to use anything different. The following database pool plan is generated from the console. The only change I made to it was the dependency to make it point to the system-database where the derby engine is running. This db pool will be deployed with the EAR application.
...
...
geronimo-application.xml tells the application that there is a database pool that needs to be deployed as well. The db pool is defined in BankPool.xml and the driver that is needs in order to be deployed is the tranql-connector-ra-1.3.rar file--these two files will reside on the top level layer of the resultant EAR file.
...
...
Sample Database
The sample database that is being used to demonstrate this application is inbuilt Derby database. The name of the sample database is BankDB and it consists of three tables, CUSTOMER ,ACCOUNT and EXCHANGE_RATE. The fields for each of these tables are described below.
...
Configuring, Building and Deploying the Sample Application Anchor configure configure
Download the bank application from the following link:
Bank
...
After starting Apache Geronimo log into the console and follow the given steps to create the BankDB.
...
...
- Select DB Manager link from the Console Navigation in the left.
- Give the database name as BankDB and click Create button.
- Select BankDB to the Use DB field.
- Open BankDB.sql in the bank directory from a text editor.
- Paste the content BankDB.sql to the SQL Commands text area and press Run SQL button.
...
To test the sample web application open a browser and type http://localhost:8080/Bank. It will forward you to the index page of banking application which has direct links to the view customer and exchange rate information. To view the list of account information of each customer, provide a relavant customer id in the DB. Exchange rate page will display list of all currencies in the exchange rate table. (Note that 'Bank' is case-sensitive)
Summary Anchor summary summary
This article has shown you how to use the EJB features of the Apache Geronimo. It has provided step-by-step instructions to build an application, deploy and run it to elaborate those features.
...