Programming Assignment 2: Basic EJBs

This assignment helps you become familiar with basic technologies for developing enterprise web applications. It involves adding Enterprise JavaBeans to the previous assignment. Along the way, you will learn how to set up an environment based on a product such as JBoss. In this assignment, we will be using the following

  • JBoss application server 4.0.3.
  • MySQL database server.
  • MySQL Connector/J (JDBC Driver).
  • EJB 2.1 specification.

    Description

    Package the code you developed for PA1 into a set of EJBs. You will need EJBs as follows:

    You should read this article to understand the basics of creating and deploying enterprise beans in Jboss. You should also download the JBoss AS Getting Started Guide 4.0.2 Rev 4 (register first) . Based on the examples, provide, create build.xml that accomplishes the following:

    1. Packages the various EJBs in java archives (jar files).
    2. Packages the web resources in a web archive (war file).
    3. Packages the entire application into a deployable enterprise archive (ear file).
    4. Deploys the enterprise archive properly into JBoss.

    Problem Details

    You need to have Home and Local interfaces for all Enterprise beans. Remote interfaces are optional (If your beans will not be used by external clients, you don't need to create a remote interface.). Your main JSP/servlet will call the session bean, which should have the following functionality by using the entity bean:
  • Creation of a new account,
  • Crediting money into the given account,
  • Debiting money from an existing account, and
  • Returning the current balance of a given account

    In addition to deployment descriptors, which you used in the previous assignment, you need the following deployment descriptors for declaring the deployment properties for enterprise beans:

  • ejb-jar.xml is the standard EJB deployment descriptor, declaring the available enterprise beans, their logical names, interfaces, and other deployment properties (security, transactions, etc.),
  • jbosscmp-jdbc.xml, contains database and relationship mapping information for the entity beans in an EJB jar.
  • jboss.xml is used to specify JNDI name for a bean's local or remote home interface. The default JNDI name for a bean is the ejb-jar.xml ejb-name element value

    Systems Requirements

    As in previous assignment, to store account information, you must use a database in the backend and communicate with it through entity bean. Install and use MySQL. The database must conform to the following schema:
  • The name of the database must be 'test_csc513pa1'
  • The name of the table must be 'Accounts'
  • It must have two columns, namely, 'id' (varchar(10)) and 'amount'(int).
  • No two rows can have the same value of 'id'.
  • Copy the docs\examples\jca\mysql-ds.xml in your JBoss directory to your deploy directory and only change the database name. The datasource name should remain as MySqlDS.

    The above schema may be implemented outside the program before running the program by using the mysql command-line client. Your program then just queries the table, and inserts and modifies rows.

    Deliverables

    Deliver the application as a .ear archive. Put your source code and the .ear file in a zip file and submit it. The .ear archive must conform to the following:
  • The name of the archive must be < your-unity-id> .ear.
  • The file application.xml must be such that I can access your application using the URL http://< server_name >:8080/< your-unity-id>. See mine.

    If your program conforms to the above, then there will be no need for a README file. Your program should work out of the box.

    Ant is a great tool for building and packaging java applications. It is similar to the GNU make utility---consider Ant its Java/XML avatar. All I do is edit my source files and invoke ant to build, package and deploy the .ear into JBoss. I highly recommend using it to build your .ear archive. See this build file. Study it carefully. It yields useful clues about the structure of your enterprise application.

    This is more or less the assignment. Further fine-tuning may be done in the next couple of days. Be sure to check out this page.