Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

About This Book

About This Book

One of the things you quickly realize when you work with any of the technologies covered by the Java EE umbrella is that many things are part of the specification, and some things are left as “implementation details” or left up to the implementer’s discretion. In practice, this means that any time you learn a Java EE technology, besides learning the fundamentals about that technology, you also need to learn how to apply or configure the technology in the environment in which you wish to deploy it. If your deployment environment of choice is the JBoss Application Server, then this book is for you because it covers those areas that are outside the scope of the specifications.

In this book, we cover a wide variety of technologies and show you how to configure those technologies specifically for use in the JBoss Application Server. Naturally, this can’t be done in a vacuum, so we provide simple examples that illustrate the technology and then walk you through the steps necessary to configure things such as deployment descriptors, access control, and encryption. Our intent isn’t to describe every nuance of any particular technology. For that, we recommend that you read books particular to those technologies (and we provide references at the end of most chapters). Instead, use this book to learn how to use the technology within the JBoss Application Server.

We believe that you learn more by trying things out for yourself than by reading about how it’s done. By keeping our examples simple, we’re able to provide complete source code, including configuration files, within the book itself. If you want, you can try the examples using only the text in the book. All you need is a text editor. But we don’t provide build scripts in the book; instead, we provide diagrams showing the contents of the resulting packages (JAR, WAR, EAR, and so on). We assume that you can use whatever tools you’re familiar with to compile and package the applications.


As programmers at heart, we wrote the book from a programmer’s point of view. Any programmer that uses the JBoss Application Server in his or her daily routine will benefit from reading this book. But we went beyond mere coding to look at what it takes to get an application configured and into production.

With its focus on configuration topics, this book is also ideal for use by system administrators who need to configure and deploy applications to the JBoss Application Server. Many of the chapter introductions guide administrators, pointing out the sections on which they should focus.


This book is divided into four parts. Part 1 covers JBoss Application Server (JBoss AS) basics. Here’s where you’re introduced to the application server, how it’s configured, and how applications are deployed; you’re also given an overview of security. Part 2 gets into individual Java EE technologies, such as web applications, enterprise applications, and messaging, and describes their configuration in detail. Part 3 covers the JBoss Portal, describing portal administration and configuration. Finally, Part 4 covers topics that you’ll want to consider when going into production—things such as performance tuning, clustering, and a whole checklist of other items.

Chapter 1 gives you a 10,000-foot view of JBoss AS by showing you how to download, install, run, and deploy into it. You’ll learn about the installation structure and where important server configuration files go. We also provide you with some history and an architectural discussion to give you a broader background on the product.

Chapter 2 provides a first look at configuring the application server. The techniques you learn here will be useful in the chapters that follow. You’ll learn how the application server is architected and, from there, how you go about configuring it. The chapter continues by describing various configuration topics not covered elsewhere and concludes with a look at some of the tools you can use to administer the application server.

Chapter 3 discusses deploying applications and contains a discussion of class loaders. From the JBoss forums, we’ve gleaned some of the common deployment errors that crop up and have provided solutions to those issues. We end the chapter describing how to deploy data sources and Hibernate archives.

Chapter 4 introduces you to security in JBoss AS. We start with a general overview of basic security concepts such as authentication and authorization. We then discuss how these concepts are implemented in JBoss AS. Finally, we show you how to configure security in JBoss, demonstrating how you can access security data from a database, LDAP, or other security datastores. After reading this chapter, you should have a general understanding of how to configure security in JBoss.

Chapter 5 discusses the JBoss AS web application server, known as JBoss Web Server. First, you’ll learn how to build and deploy web applications. Then, you’ll learn the basics on how to configure web applications and JBoss Web Server. Finally, we build on the basic configuration knowledge to show you a number of practical things that you can configure in your web applications.

Chapter 6 merges the discussions in chapter 4 and chapter 5 to show you how to configure security for web applications. We’ll teach you how to use all the standard web authentication models and how to tie them into your own security datastore. We’ll also teach you how to use secure public-key communication to encrypt access to your site.

Chapter 7 talks about EJB applications and the EJB server, the heart of JBoss AS. We show you how to structure, deploy, and configure EJB applications. Then, we show you how to configure the application server, enabling you to do things such as change the communication transport and secure EJB applications.

In chapter 8, you’ll learn about configuring JBoss Messaging, which is the JMS-com-pliant messaging server bundled with the JBoss Application Server. The chapter starts off describing JMS and how JBoss Messaging is architected. We present a simple messaging client application and then expand it to include a message-driven EJB and a message-driven POJO. We use this client to describe messaging configuration topics such as changing the messaging store to use another database, defining your own destinations, providing access control, and encrypting messaging data.

Chapter 9 covers JAX-WS–based web services. After a brief introduction into web services, we present a simple POJO-based web service and its client. We expand the example by converting the web service into an EJB, and developing a C# client for the web service. We use the example to describe various configuration topics such as describing the web service using both annotations and descriptor files, configuring access control, and using WS-Security to both encrypt and sign web service messages.

Chapters 10 and 11 provide an introduction into the JBoss Portal. Chapter 10 starts with a description of portals in general and the JBoss Portal in particular. We explain how to install the Portal and set it up to use a database. Then, we provide an example portlet that’s a little more complex that the other examples in this book because we want to highlight various portlet coding techniques. We then use the example to describe how to configure the Portal to include the portlet, using both configuration files and the Management Portlet. In chapter 11, you’ll learn how to use the Content Management System (CMS) that comes with the JBoss Portal, and how to define access control for your portal and portlets. The chapter ends with a section that puts everything you learn together to create a custom portal.

Chapter 12 introduces clustering in JBoss AS. This chapter talks about the basics of clustering and shows the location of all the configuration files and how to configure the underlying clustering services. You’ll set up a simple cluster in this chapter and learn how to configure JGroups and JBoss Cache.

Chapter 13 builds on this background from chapter 12 to show you how to configure clustering for specific services. You’ll learn how to configure HTTP load balancing and HTTP session replication, how to cluster session EJBs, how to cluster entities, and how to configure high-availability JNDI.

In chapter 14, we present ways to assess the performance of your deployed applications and practical steps for improving the performance. We examine performance using a holistic approach, looking at tuning the hardware, operating system, database, JVM, application server, and your application. We give detailed information on properly sizing the Java heap, and tips on how to interpret thread dumps to pinpoint performance issues within your code.

We end the book in chapter 15 with a checklist of items you’ll want to consider when moving your applications into production. Besides referring you back to prior chapters for topics we’ve already covered (such as clustering and performance tuning), we cover such topics as selecting the proper platform (operating system, JVM, and application server), running multiple instances of the application server on a single host, slimming the application server by removing services you don’t need, securing or removing the default applications, replacing the Hypersonic database with a production-worthy database, configuring the application server to run as a service so that it will start up automatically when the server is booted, and configuring JSP compilation.

Appendix A discusses JNDI. First, you’ll learn about how to configure the Environment Naming Context, allowing you to define local names for your resources and beans. Then, we show you how to explore what’s in JNDI by using the JMX console.

Appendix B covers last-minute changes to JBoss AS that were made too late to be included in the earlier chapters because they had already gone to the printer. We held off on sending this appendix to the printer for as long as possible to get you all of the latest JBoss AS developments.

Source code conventions and downloads

The source code for the various examples in this book is available for download from After downloading the zip file, unzip it, and open the index.html file in the base directory using your favorite browser. (We recommend Firefox.) That file provides all the information you need to build, deploy, and experiment with the examples. And we provide build scripts!

All source code in listings or in text is in a fixed-width font like this to separate it from ordinary text. Occasionally, text or commands that should be all on one line are wrapped to two or more lines. In such cases, the continuation lines begin with a continuation character (,) as in this example:

Pay close attention to the continuation characters when used in an XML file listing. Often, the service reading the XML won’t trim whitespace characters from the text, causing the text to be misinterpreted. For example, consider the following example XML:

You should type it, as follows:

     <some-stuff>really great stuff</some-stuff>

Most example commands are provided in an operating system–neutral fashion rather than showing the command twice, once for Windows and again for Linux. Consider the following generic command:

     wsrunclient –classpath target/dist/client.jar

Notice two things: First, we provide the script name without any suffixes or prefixes, and we use forward slashes as directory separators in file names. This command would be entered in Windows as

     wsrunclient –classpath target\dist\client.jar

And in Linux as

     ./ –classpath target/dist/client.jar

Unless otherwise specified, all relative paths are within the JBoss Application Server installation directory. In addition, we use the text xxx to mean any of the configurations within the server directory. As an example, if you install JBoss AS at c:\jboss-5.0.0.GA, then the text server/xxx/conf/jboss-service.xml refers to the files c:\jboss-5.0.0.GA\ server\default\conf\jboss-service.xml, c:\jboss-5.0.0.GA\server\all\conf\jboss-service.xml, and to any similarly located jboss-service.xml files in other configurations you might have in the c:\jboss-5.0.0.GA\server directory.

Code annotations accompany many of the listings, highlighting important concepts. In some cases, numbered bullets link to explanations that follow the listing.

If you have the PDF version of this book, beware of copying example code from the PDF file to a command line or text editor. For example, the dash character (-) within the PDF file is typically not the dash character (ASCII character 0x2D) expected by software. You’ve been warned.

On versions of JBoss middleware

Writing a book about a version of the JBoss Application Server that hasn’t reached general availability (GA) is a calculated risk. When we started this project in the summer of 2006, 4.0.4 was the latest version with talk of the 5.0 version being released early in 2007. We figured that by the time we got the book done, 5.0 would be out. Well, in the spring of 2007, 4.2.0 came out, and 5.0 was only at beta 2. We put the book on hold until 5.0 beta 3 came out; when beta 4 came out soon after, it had so many changes that once again we put the book on hold until CR1, and then verified again on CR2 before starting to send the chapters to the printer.

Although we’ve endeavored to ensure that the configuration settings we provided will be correct for the final release, there are no guarantees. We recommend that you check the website for the book ( for any addendums. But, we will ensure that the source download works correctly with JBoss AS 5.0.0.GA within two or three weeks after it’s released. Check the index.html file in the source code download for the exact version that it works with.

JBoss Portal is a different story. The chapters on the portal are based on the 2.6.4.GA release running on JBoss AS 4.2.2, and were later verified with JBoss AS 4.2.3 and Portal 2.7.0. As of this writing, there’s no clear roadmap of which version of the Portal will work with JBoss AS 5.0.0.GA. We will put a notice in the Author Online forum when this situation changes.

Author Online

Purchase of JBoss in Action includes free access to a private web forum run by Manning Publications where you can make comments about the book, ask technical questions, and receive help from the authors and from other users. To access the forum and subscribe to it, point your web browser to This page provides information on how to get on the forum once you’re registered, what kind of help is available, and the rules of conduct on the forum.

Manning’s commitment to our readers is to provide a venue where a meaningful dialogue between individual readers and between readers and the authors can take place. It isn’t a commitment to any specific amount of participation on the part of the authors, whose contributions to the book’s forum remain voluntary (and unpaid). We suggest you try asking the authors some challenging questions, lest their interests stray!

The Author Online forum and the archives of previous discussions will be accessible from the publisher’s website as long as the book is in print.

About the authors

Javid (pronounced JAW-veed) Jamae has been a programmer his whole life, starting on Applesoft BASIC at a young age and dabbling with a myriad different programming languages before getting paid to write code in Java in the late 90s. Working as a consultant, trainer, and software coach for several years, Javid had the opportunity to work on many different projects in many different industries. Javid has also published many Java-related online and print articles over the last several years. Javid lives in Houston with his wife and three kids and is currently plotting ways to start the next multi-billion-dollar software company.

Peter Johnson started his computer career in 1980 supporting a COBOL accounting package running on a Burroughs mini-computer. He started working in Java in 1998, and was lead designer on projects such as a JDBC driver for the DMSII database that runs on Unisys mainframes. For the past several years, he has been chief architect on a team that analyzes performance of Java applications on large-scale Intel-based machines (8 to 96 CPUs) and evaluates various open source software for enterprise readiness. Peter speaks often about Java performance and JBoss technologies at industry conferences such as the Computer Measurement Group conference, Linux World, and JBoss World.

About the title

By combining introductions, overviews, and how-to examples, the In Action books are designed to help learning and remembering. According to research in cognitive science, the things people remember are things they discover during self-motivated exploration.

Although no one at Manning is a cognitive scientist, we are convinced that for learning to become permanent it must pass through stages of exploration, play, and, interestingly, retelling of what is being learned. People understand and remember new things, which is to say they master them, only after actively exploring them. Humans learn in action. An essential part of an In Action book is that it’s example-driven. It encourages the reader to try things out, to play with new code, and explore new ideas.

There is another, more mundane, reason for the title of this book: our readers are busy. They use books to do a job or solve a problem. They need books that allow them to jump in and jump out easily and learn just what they want just when they want it. They need books that aid them in action. The books in this series are designed for such readers.

  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint