Using Geronimo to drill down into an EJB Web application

Source: Internet
Author: User
Tags command line object model

Learn more about the internal work of a powerful Geronimo application server and how to use it to develop database applications. Java developer Neal Sanche This trip with the article "Three ways to connect the database to the Geronimo Application Server" (developerworks,2005 year June), which guides you through creating a simple phone book database application. In this article, you will learn how to extend the initial database application and provide a functional user interface built using the Apache Struts and Enterprise JavaBeans (EJB) backend. You will also learn how to build, package, and deploy phone book database applications using the Apache Maven build system. Learn how to simplify your enterprise WEB application development process through this article.

Technology Overview

Before you learn the sample application, you need to learn more about the three technologies that will be used to create and deploy the application. (For more information on each of these technologies, see resources.) )

Maven is an application that builds Java applications, from source code to package to WEB sites. The Geronimo application server is built using the build system of the Maven application. Within its core, Maven's extensible framework allows you to create modules to perform some of the actions needed to build software components. Speaking of Apache Ant (Java build tool), Maven's actions have been compared with the results generated using UNIX command make. The Maven script also allows the application to be automatically deployed to the running Geronimo server. This article shows you how to use Maven to package your source code into a complete Java 2 Platform, Enterprise Edition (EE) enterprise application.

Struts is a WEB application framework based on the Model 2 architecture (see Resources for a complete description of JSP Model 2). This hybrid architecture minimizes business logic and display logic. Struts achieves this by isolating business logic into pure Java classes, pure Java classes manipulate data, and provide a rich tag library that can be used to display data when writing JavaServer Pages (JSPs). (in countless WEB development frameworks, many frameworks are highly popular, such as Tapestry and JavaServer Faces, and Struts has always been my favorite.) )

XDoclet originates from the long-standing Java document tool Javadoc. XDoclet developers initially used Javadoc in a novel way, using specialized annotations to generate models that could be compiled into source code. They pulled out of the actual use of Javadoc, producing their own variants, called Xjavadoc. However, in the early days of XDoclet, it was still necessary to use tags in the Javadoc comments of the source code to automate the production of auto-generated code. Writing the source code and deployment descriptor files in the Java EE application can be tedious. For every 100 lines of Java code, it is expected to generate at least three times times the number of support EE descriptor code to complete the work. To significantly reduce the pain of developing multi-tier enterprise applications, XDoclet provides code markup and code generation to automate most of the deployment descriptors. This hides the complexity of Java EE, but you need to be aware of what the Code Builder is building, because you have to check it when things don't go as planned.

Deployment plan

As mentioned in the introduction, Maven was used by the Geronimo team to build the entire application server. You can leverage the power of the Maven build tool to compile application source code, execute code generation (requiring XDoclet help), bind enterprise application modules, and eventually deploy them to a running Geronimo server.

The process starts with three files. The first file Project.xml defines what is called the Project object Model (Project Objects Model,pom). It lists information about the application, including the application name, the creator, the version number, the dependencies that are important to building the application, and an overview of how to build the application. For the purposes of this article, we will focus on the dependencies section of POM. (Resources have links to the entire POM file.) )

Maven uses the Project.xml dependencies section to download artifacts needed to build an application from a specified repository on the Internet. Ibiblio (see Resources) is a repository of hundreds of open source Java libraries and supporting files, together with POM information for these libraries. It collects a lot of information for the purpose of simplifying the life of Java developers during application building. The dependencies section of the phone book application Project.xml file consists of 23 dependencies, half of which are. jar files that support Struts and Displaytag tag libraries. The rest of the dependencies are primarily XDoclet requirements. Without Maven, each dependency needs to be bundled with the sample application.

Maven loads all dependent artifacts only the first time the application is compiled. A later compilation runs a local repository that leverages Maven (a local cache of downloaded artifacts, usually located under the. Maven directory in the $HOME directory) to obtain artifacts.

Install Maven 1.0.2

Our sample application requires some initial setup of Maven to make everything work correctly. First, you need to install MAVEN 1.0.2 (see Resources for the MAVEN Web site link). After the installation is complete, enter maven at the command line, and you will see information similar to the following:

E:\Documents and Settings\Neal\My Documents\eclipse\workspace\Phonebook> maven
__ __
| \/ |__ _Apache__ ___
| |\/| / _` \ V / -_) ' \ ~ intelligent projects ~
|_| |_\__,_|\_/\___|_||_| v. 1.0.2

Compiling Geronimo

Then, follow the instructions on the Wiki (see Resources) to compile Geronimo from the source code. After a successful build, the Geronimo artifact will be located in the local repository. They are necessary to build the sample application. After you compile Geronimo, look for the Geronimo-deployment-plugin-1.0-snapshot.jar file and install it in the $MAVEN _home/plugins directory, or you may see the following message:

Tag library requested that is not present: 'geronimo:deploy' in plugin: 'null'

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.