O'Reilly logo

JBoss at Work: A Practical Guide by Scott Davis, Tom Marrs

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required


Are you curious about the cool, new features of JBoss 4 and J2EE 1.4? Are you frustrated with all the simplistic “Hello World” examples? Do you want to see a realistic application deployed on JBoss?

As practitioners, we’ve seen that most people struggle with the following issues when deploying J2EE applications on JBoss:

  • Real application deployment involves many J2EE and JBoss deployment descriptors, and it’s difficult to make them all work together.

  • Developers new to JBoss need a way to get started.

  • Most projects don’t have a packaging and deployment strategy that grows with their application.

  • Class Loaders are confusing and can cause problems when developers don’t know how to use them.

This book shows you how to use JBoss with the latest Open Source Java tools. By building a project throughout the book with extensive code examples, we cover all major facets of J2EE application deployment on JBoss, including JSPs, Servlets, EJBs, JMS, JNDI, Web Services, JavaMail, JDBC, and Hibernate.

With the help of this book, you’ll:

  • Implement a full J2EE application and deploy it on JBoss.

  • Discover how to use the latest features of JBoss 4 and J2EE 1.4, including J2EE-compliant Web Services.

  • Master J2EE application deployment on JBoss with EARs, WARs, and EJB JARs.

  • Understand the core J2EE deployment descriptors and how they integrate with JBoss-specific descriptors.

  • Deploy JSPs, Servlets, EJBs, JMS, Web Services, JavaMail, JDBC, and Hibernate on JBoss.

  • Base your security strategy on JAAS.

Although this book covers the gamut of deploying J2EE technologies on JBoss, it isn’t an exhaustive discussion of each aspect of the J2EE API. This book is meant to be a brief survey of each subject aimed at the working professional with limited time.


This book is for Java developers who want to use JBoss on their projects. If you’re new to J2EE, this book will serve as a gentle introduction. But don’t mistake this book for a true J2EE reference manual. There is a reason those books are 1,000+ pages long—they cover each technology in exhaustive detail. This book gives you enough to get a simple example up and running quickly.

If you’ve worked on J2EE projects but are new to JBoss, this book covers familiar concepts, introduces you to key J2EE 1.4 issues including Web Services, and shows you how to make them work with JBoss. If you’ve worked with JBoss before, this book will get you up to speed on JBoss 4, JBoss WS (Web Services), and Hibernate 3.

About This Book

This book starts with a simple web page and iteratively shows you how to add the various J2EE technologies to develop an application that runs on JBoss. Rather than getting stuck in the details of every possible J2EE API or J2EE/JBoss deployment descriptor, we focus on learning by doing. We introduce you to each topic, show what we’re going to do, do it, and recap what we did. By taking an iterative approach, we keep things short, sweet, and to the point so that you can put JBoss to work on your projects.

Assumptions This Book Makes

We assume that you’ve worked with Java and are familiar with Open Source tools such as Ant and XDoclet. We show you how to download and install them. We provide you with Ant scripts for compiling and deploying the application.

Conventions Used in This Book

The following typographical conventions are used in this book:

Plain text

Indicates menu titles, menu options, menu buttons, and keyboard accelerators (such as Alt and Ctrl).


Indicates new terms, URLs, email addresses, filenames, file extensions, pathnames, directories, and Unix utilities.

Constant width

Indicates commands, options, switches, variables, attributes, keys, functions, types, classes, namespaces, methods, modules, properties, parameters, values, objects, events, event handlers, XML tags, HTML tags, macros, the contents of files, or the output from commands.

Constant width bold

Shows commands or other text that should be typed literally by the user.

Constant width italic

Shows text that should be replaced with user-supplied values.


This icon signifies a tip, suggestion, or general note.


This icon indicates a warning or caution.

Using Code Examples

This book is here to help you get your job done. In general, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.

We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: "JBoss at Work: A Practical Guide, by Tom Marrs and Scott Davis. Copyright 2005 O’Reilly Media, Inc., 0-596-00734-5.”

If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at .

Safari Enabled

When you see a Safari® enabled icon on the cover of your favorite technology book, that means the book is available online through the O’Reilly Network Safari Bookshelf.

Safari offers a solution that’s better than e-books. It’s a virtual library that lets you easily search thousands of top tech books, cut and paste code samples, download chapters, and find quick answers when you need the most accurate, current information. Try it for free at http://safari.oreilly.com.

Comments and Questions

Please address comments and questions concerning this book to the publisher:

O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
(800) 998-9938 (in the United States or Canada)
(707) 829-0515 (international or local)
(707) 829-0104 (fax)

We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at:


We also have a companion web site for this book, where we have an FAQ, links to resources, and bonus materials. Please visit:


To comment or ask technical questions about this book, send email to:

For more information about our books, conferences, Resource Centers, and the O’Reilly Network, see our web site at:



Many people contributed to this book’s development. We’re grateful to Mike Loukides, our editor, for his experience, guidance, and direction. We’d like to thank him for believing in us and being patient with two first-time authors as we learned our craft.

We had a great team of expert technical reviewers who helped ensure sure that the material was technically accurate, approachable, and reflected the spirit of the JBoss, J2EE, and Open Source communities. Our reviewers were Norman Richards, Greg Ostravich, Andy Ochsner, and Dan Moore. Their suggestions and corrections greatly improved the quality of the book. We’re especially thankful to Norman Richards of JBoss, Inc. for his quick turnaround on show-stopper issues and for all his great advice.

We owe a great debt to the Open Source community who made the tools for this book:

  • To JBoss, Inc. for creating and maintaining JBoss, an outstanding and reliable J2EE application server that we use on our jobs every day. JBoss is great and we love it. We hope that the concept of Professional Open Source will continue to blossom and grow.

  • To the Ant, XDoclet, Log4J, Apache Jakarta, Hibernate, and (numerous) Apache and SourceForge projects—you guys rock! Your tools keep the Java community going.

Tom’s Acknowledgments

I am especially thankful to Scott Davis, my co-author, for exhorting me to finish the book, holding me accountable, and for pushing me to improve my writing style. This book would’ve been impossible without him.

Thanks to Richard Monson-Haefel, Sue Spielman, Bruce Tate, Brett McLaughlin, Frank Traditi (my business coach), the Denver Java Users Group (DJUG—http://www.denverjug.org), and everyone else who encouraged me along the way.

Thanks to Jay Zimmerman, coordinator of the “No Fluff Just Stuff” (http://www.nofluffjuststuff.com) conferences, for enabling me to take my message on the road.

Thanks to The One Way Café in Aurora, CO—keep the lattes and good advice flowing.

Most importantly, I am deeply grateful to my wife, Linda, and daughter, Abby, for supporting me during the writing process. I love you and look forward to spending more time together.

Scott’s Acknowledgments

Tom came to me with an opportunity to co-author a book for O’Reilly. How could I possibly turn down a gig like that? Tom and I have known each other for years, and we knew from the start that we brought complementary skills to the table. This book was a collaborative effort in every sense of the word, but it never would have happened if Tom hadn’t planted the first seed.

What started out as a wildly optimistic (and in retrospect, totally unrealistic) attempt to map out the entire known world of Open Source J2EE development eventually got distilled down to the book you are now holding. Even though this book is far more modest in scope than our original idea, I think that it still captures the spirit of what we set out to accomplish. Without getting bogged down in the whole commercial versus free versus open source quagmire, we wanted to show you that it is possible to create a production-quality application using nothing but freely available tools.

Thanks go out to the Denver and Boulder JUG communities—hanging out with all of you (too numerous to mention individually) has made me a better programmer and a better person. When I was a lone wolf contractor, your emails and IMs, phone calls and lunches, but especially the post-meeting pints and horror story-swaps are what kept me sane through all of it. When I was new to a city and a programming language, you made me feel like I belonged.

A very warm thanks goes out to Jay and the whole NFJS crew (Ted, Bruce, Erik, Jason, James, Mike, Stu, Justin, Glenn, David, Eitan, Dion, Ben, Dave, and the rest of y’all). After attending my first conference, I knew that I wanted to be a part of it professionally. The collective talent and charisma of the speakers is breathtaking. During a Fourth of July celebration, my three year-old son Christopher said in awe, “Daddy, the fireworks are too big for my eyes.” No exaggeration—I feel the same way when I’m on the NFJS tour.

But my deepest thanks and love goes to my family: Kim, Christopher, and little soon-to-be-born Baby X. I did my best to keep my writing hours limited to after bedtime and during naptime (Mom’s and son’s both), but I know that it crept into the waking hours as well. Thanks for pretending for my benefit that it didn’t matter. You are my everything.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required