The Official JBoss Development and Administration Guide
Authors: Marc Fleury
Venue:  (2002)

From the Book:Introduction About This Book This book is for the JBoss content developer and administrator. The topics covered are those necessary to install, configure, and use version 2.4.x of the JBoss Open Source application server. About Open Source "The basic idea behind open source is very simple: When programmers can read, redistribute, and modify the source code for a piece of software, the software evolves. People improve it, people adapt it, people fix bugs; this can happen at a speed that, if one is used to the slow pace of conventional software development, seems astonishing. We in the open source community have learned that this rapid evolutionary process produces better software than the traditional closed model, in which only a very few programmers can see the source and everybody else must blindly use an opaque block of bits. Open Source Initiative exists to make this case to the commercial world. Open source software is an idea whose time has finally come. For twenty years it has been building momentum in the technical cultures that built the Internet and the World Wide Web. Now it's breaking out into the commercial world, and that's changing all the rules. Are you ready?" About J2EE The Java 2 Platform, Enterprise Edition (J2EE), defines the standard for developing multitier enterprise applications. J2EE simplifies enterprise applications by basing them on standardized, modular components, by providing a complete set of services to those components, and by handling many details of application behavior automatically, without complex programming. The J2EE platform encompasses a number of technologies. J2EE: A Standard Web Operating System with Industry Momentum Sun Microsystems, IBM, and a host of industry participants have deemed J2EE a standard as defined through the Java Community Process (JCP, http://www.jcp.org). Today, there are about 30 J2EE application server vendors. The most popular charges more than $50,000 for a medium-sized installation. The goal of the J2EE standards is to simplify the enterprise development process as well as improve portability of components between vendor J2EE implementations. Enterprise developers can draw on J2EE to speed up their application development. Instead of writing database code by hand, or pooling management, they can leverage Enterprise Java Beans (EJBs) to automatically manage data. Instead of manually dealing with transactions, system developers can use J2EE's built-in capabilities to run transactions in an automated fashion. Instead of creating all business code from scratch, consultants can assemble components to build their application in a "Lego" fashion. J2EE APIs J2EE is a set of standards that, when used together, provide an excellent Web application development and deployment platform. J2EE includes standards for middleware (EJB and JMS), database connectivity (JDBC), transactions (JTA/JTS), presentation (servlets and Java Server Pages), and directory services (JNDI). A summary of the range of APIs/technologies included in J2EE is given in Table I.1. Table I.1 The J2EE APIs and Their Descriptions API Name Description (JavaSoft URL) EJBs Enterprise JavaBeans (http://java.sun.com/products/ejb) CORBA Common Object Request Broker Architecture (http://java.sun.com/j2ee/corba) Servlets Java Servlets (http://java.sun.com/products/servlet) JNDI Java Naming and Directory Interface (http://java.sun.com/products/jndi) JDBC Database Connectivity (http://java.sun.com/products/jdbc) XML Extensible Markup Language (http://java.sun.com/xml) JMS Java Message Service (http://java.sun.com/products/jms) JTA/JTS Transactions (http://java.sun.com/j2ee/transactions.html) Connector Enterprise Information Systems Connector (http://java.sun.com/j2ee/connector) JSP Java Server Pages (http://java.sun.com/products/jsp) For additional information on the technologies of the J2EE platform, see the URLs referenced in Table I.1, or see the JavaSoft J2EE home page at http://java.sun.com/j2ee. Why Open Source for J2EE? As a Web operating system, J2EE is infrastructure. As such, we believe it is a natural fit for the collaborative, Open Source mode of development facilitated by the Internet. Our group, composed of volunteers from around the world, chooses to open the server and container development. Our belief is that there should be an Open Source J2EE server environment that makes J2EE available to anyone. The extreme size and complexity of this sort of operating system is yet another compelling reason for it to exist in Open Source. Even Microsoft has had difficulties stabilizing Windows 2000. We at JBoss believe that Open Source technology is a credible, efficient and cost-effective way to scale the development of these large systems. Who Uses J2EE Technology? As seen from Table I.1, the range of middleware functionality covered by the J2EE platform is quite extensive. These technologies can be used as a single comprehensive platform, individually as an enabling technology, or even as a single component. This leads to the question of how the technologies of the J2EE platform are used, and by whom. The following list provides some example of who is making use of J2EE. Independent software vendorsTwo years ago, many independent software vendors (ISVs) developing Enterprise applications took the Java route. ISVs develop in-house proprietary infrastructure software because of the lack of a defined, open standard. This development is time-consuming, expensive, and complex. Today, most ISVs outsource that infrastructure development to a J2EE server vendor to be able to focus more on business logic. Choosing an open source server makes sense from a pricing standpoint because the application price won't reflect the infrastructure cost. It also makes sense from a technological standpoint because you have access to the code, which makes for a tighter integration with applications. According to our statistics, about 20% of people who download JBoss do so with the objective of embedding it in their applications. IT departments and startupsA recent study showed that Java/J2EE, which claims 60 percent of IT development, is already the dominant platform for Enterprise Web Software. Most people use our container as a stand-alone Web application server. In many instances, we have been chosen over more pricey competitors for both development and production. We sport features such as hot deploy, runtime-generated stub, and skeleton objects (distributed invocation enablers) that can't be found in most commercial tools...no matter how much you are willing to pay! ISP/ASP, the next wave of Enterprise Software HostingMost ISP providers already offer Web Hosting for static Web pages. For more enterprise level hosting, you need a J2EE platform. Going beyond simple logic and cgi-bin, JBoss was designed for Application Service Provider (ASP) settings. You can deploy its applications on a set of hosted machines, and have a Web-based Java Management Extension (JMX) console to manage the remote servers. Our integration with Java Server Page (JSP) engines makes JBoss the candidate of choice for ISP usage. While most J2EE vendors do not focus on this market, JBoss is well suited for it in two ways. First, the code is modular so you can administer various configurations to fit every client's specific needs. Second, there is no license fee per CPU, so you can grow a J2EE server farm at little cost. Module and third-party developersBehind JBoss' Open Source success is a highly modular design, which allows us to scale development and integrate code. From the ground up, JBoss is built around the concept of modules and plug-ins. We use the JMX specification to configure and administer the different plug-ins. We integrate various modules, from Tomcat to cocobase, to offer a state-of-the-art J2EE container. By integrating in JBoss, developers gain access to the dominant application development market and increase the deployment potential for their technology. About JBoss JBoss, one of the leading java Open Source groups, integrates and develops these services for a full J2EE-based implementation. JBoss provides JBossServer, the basic EJB container, and Java Management Extension (JMX) infrastructure. It also provides JBossMQ, for JMS messaging, JBossTX, for JTA/JTS transactions, JBossCMP for CMP persistence, JBossSX for JAAS based security, and JBossCX for JCA connectivity. Support for web components, such as servlets and JSP pages, is provided by an abstract integration layer. Implementations of the integration service are provided for third party servlet engines like Tomcat and Jetty. JBoss enables you to mix and match these components through JMX by replacing any component you want with a JMX compliant implementation for the same APIs. JBoss doesn't even impose the JBoss components. Now that is modularity. JBoss: A Full J2EE Implementation with JMX Our goal is to provide the full Open Source J2EE stack. We have met our goal, and the reason for our success lies on JMX. JMX, or Java Management Extension, is the best weapon we have found for integration of software. It provides a common spine that allows one to integrate modules, containers, and plug-ins. Figure I.1 illustrates how JMX is used as a bus through which the components of the JBoss architecture interact. Figure I.1 The JBoss JMX integration bus and the standard JBossXX components. While we provide JBoss implementations for many of these services, you are free to include your favorite implementation in the JMX enabled base, therefore dropping your own transaction or persistence service in JBoss, all dynamically. JBoss Architecture Overview This section provides an overview of the components that ship with the standard JBoss 2.4 distribution. The various named elements in Figure I.1 correspond to JBoss components as follows. The JMX bus, EJB container, and remote management elements are the domain of the JBossServer component while the JMS element corresponds to the JBossMQ component. The JTS/JTA element corresponds to the JBossTX component, and the Databases element represents persistent store of objects as managed by the JBossCMP component. The Security element responsibilities are the domain of the JBossSX component. The Data Sources element includes an example of a managed resource, and integration of resource is the domain of the JBossCX component. The Java Server Pages element corresponds to servlets as well as JSP Web components. Support for Web components is handled by JBoss Web server integration services. JBossServer In addition to the fact that JBoss/Server is an EJB 1.1-compliant application server, there are some innovative features that make our server a pleasure to use. Specifically, two features make application deployment extremely easy to perform, saving developers much time and effort. JBoss/Server takes the grunt work out of EJB application development. First, there's dynamically, runtime-generated stub and skeleton classes. In many commercial EJB servers, the generation of these classes must be performed in an additional step prior to deployment (such as using an ebjc tool). It goes without saying that this extra step requires additional developer overhead, adding significant time to each change-compile-deploy cycle. By generating stub and skeleton classes on the fly, JBoss/Server takes at least several seconds, and perhaps minutes, off of each deployment. As an added benefit, the method used by JBoss/Server to accomplish this time- and effort saving feature also conserves memory and other server resources because only a single server object supports every deployed Enterprise JavaBeans component. A second time- and effort saving feature is automatic hot deploy and redeploy. Some of the top commercial EJB servers require you to bounce the server to be able to successfully deploy your application changes. However, JBoss/Server allows you to deploy new applications and redeploy existing applications without stopping and restarting the server. In fact, the feature is as easy as copying your newly built EJB JAR file to the server deployment directory where JBoss/Server picks up the new file, automatically undeploys the old JAR (if any), and deploys the new JAR within seconds. This feature definitely provides the benefit of slicing minutes off of each change-compile-deploy cycle. JBossMQ JBossMQ (originally spyderMQ) was released in April 2000 as the first free implementation of the Java Messaging Service (JMS) specification. Based on the 1.0.2 JMS specification, JBossMQ is a clean room, pure java implementation. It is not uncommon for the Web to fail, for nodes to fail, and for communications in general to fail. Therefore, distributed applications cannot always depend on a synchronous messaging model to reliably deliver notifications. That's why, in addition to synchronous messaging, JMS also provides an asynchronous messaging model that implements the Publish/Subscribe design pattern. A Publish/Subscribe model is critical for successful collaboration between the various participants of a distributed, e-business application. We believe JMS, through our JBossMQ com- ponent, plays a central role in the J2EE-based Web operating system provided by the JBoss. Every aspect of the JMS 1.0.2 spec has been implemented, including Both point-to-point and publish-subscribe style messaging Durable subscribers JMS Application Server Facilities The ability to participate in global units of work coordinated by a transaction manager JBossMQ supports several different kinds of message transport/invocation layers that include RMIRMI-based invocation layer. OILOptimized Invocation Layer. This layer uses custom TCP/IP sockets to obtain good network performance and small memory footprint. UILFor client applications that cannot accept network connections originating from the server. JBossTX JBossTX is a transaction monitor with JTA/JTS support. The Java Transaction Service (JTS) specifies the implementation of a Transaction Manager, which supports the Java Transaction API (JTA) 1.0 specification at the high level and implements the Java mapping of the OMG Object Transaction Service (OTS) 1.1 specification at the low level. JTA allows you to demarcate transactions in a manner that is independent of the transaction manager implementation. JBossTX implements the transaction manager with the Java Transaction Service (JTS), but your code doesn't call the JTS methods directly. Instead, it invokes the JTA methods, which then call the lower level JTS routines. JBossTX offers the following services: Provides applications and application servers the capability to control the scope and duration of a transaction Allows multiple application components to perform work that is part of a single, atomic transaction Provides the capability to associate global transactions with work performed by transactional resources Coordinates the completion of global transactions across multiple resource managers Supports transaction synchronization JBossCMP During development of JBoss/Server version 1.0 (then known as EJBoss), we put together an object-to-relational (O-R) mapping tool. Enter JAWS, the acronym for Just Another Web Storage, which is an API for mapping Enterprise JavaBeans objects to relational database persistent stores. JAWS has since been renamed JBossCMP and the project has since taken on a life of its own. That's because we are not only maintaining and enhancing the original code base that defined a simple, yet proprietary O-R mapping tool. We are also extending the product to support the popular third-party O-R mapping tools being employed by some JBoss/Server users. The Minerva JDBC connection pooling module has been added to the codebase. This module complements JBossCMP by adding a pluggable connection pooling mechanism. O-R mapping technology grew out of the differences between how object-oriented languages represent objects in memory and how relational databases store data on disk. Objects in the Java language might contain only primitive data types, such as int, double, and very simple aggregate objects such as String, making it easy to express the object's layout on disk. In the case of storing such a simple object in a flat disk file, you would just write each primitive data type variable and each String object in their string form sequentially into the flat file. As you can imagine, reading such objects back from disk into a memory-based object would be just as easy. However, what about storing more complex objects such as those that contain other objects that contain yet other objects? And what about storing both simple and complex objects into relational databases? Of course, the more complex the object that must be stored, the more intelligent the O-R mapping tool must be. An O-R mapping tool must understand how to traverse the complex object's memory graph and figure out how to store it to and read it from the persistent store. To add to the complexity, the graph of a single object might contain multiple objects that each reference a single, unique object, and it could also contain objects that recursively reference themselves or the original object. In these cases, the O-R mapping tool would have to avoid persisting the same object multiple times, perhaps even ending up in an endless loop because of the self-referencing composition! On the other hand, all complex Java objects finally boil down to variables of primitive data types and those of class String. Therefore, while it can be quite challenging to persist very complex objects, it is not impossible. There is definitely light at the end of the tunnel. The JBossCMP features include CMP 1.1 implementation JDBC 1.0, 2.0 compatible Table creation at deploy time Flexible configurable datatypes Differential metadata Multiple DataSources support Full java object support Collections supported EJB-references supported Low admin overhead in automated mode Advanced table mapping Complex finders support Pre-defined mappings to 17 JDBC databases, including Oracle, SQLServer, DB2, Sybase, PointBase, Cloudscape, HypersoncicSQL, PostgreSQL, mySQL, and more JBossSX JBossSX is a security service integration layer that supports both non-JAAS and JAAS based security implementations. J2EE provides for a limited role based declarative security model, but does not specify how roles are obtained from the operation environment. This is an implementation detail left to the application server. JBossSX provides the standard J2EE security implementation layer and a great deal more. In our product security, you will find features that you won't find anywhere elseno matter how much you are willing to pay. The key features of JBossSX are as follows: Secure authentication of users via JAAS login modules Extensible authentication of users via JAAS login modules Support for custom per method authentication of users via integration with the EJB container method interceptor Support for JAAS Subject based authorization of users Flexible mapping from legacy security systems to JAAS Subject based permissions JBossCX JBossCX is the JBoss-specific part of a JCA implementation; it takes care of handling resource adapter deployment, interfacing to the JBoss transaction and security services, and making services available through JNDI. Essentially, it's plumbing. The J2EE Connector Architecture (JCA) specifies how J2EE application components can access connection-based resources. The JCA will be a required part of J2EE 1.3. The key features of JBossCX are as follows: Support for resource adapters that support local transactions, XA transactions, and for those that don't support transactions at all. Flexible resource principal mapping architecture. Currently the only principal mapping scheme implemented is to a single resource principal per connection factory. Support for basic password credentials. Resource adapters can be automatically deployed by placing the resource adaptor archive (RAR) into the JBoss deployment directory, just like other J2EE components. Web Servers The 2.4.x version of JBoss includes two services for Web containersa Tomcat 3.2.4 service, and a Jetty 3.x service. Using one of these Web services requires non-trivial modification of the JBoss configuration as well as the servlet engine. Because of this, we provide pre-configured bundles of JBoss/Tomcat and JBoss/Jetty that provide a complete J2EE compatible solution. What this Book Covers The primary focus of this book is the presentation of the standard JBoss components, from the perspective of both configuration and architecture. As a user of a standard JBoss distribution you will gain an understanding of how to configure the standard components. In addition, the final chapter presents a detailed discussion of building and deploying an enterprise application to help you master the details of packaging and deploying applications with JBoss. As a JBoss developer, you will acquire a thorough understanding of the architecture and integration of the standard components to enable you to extend or replace the standard components for your infrastructure needs. You will also learn how to obtain the JBoss source code, along with how to build and debug the JBoss server. © Copyright Pearson Education. All rights reserved.