JBoss AS 5 Development
()
About this ebook
JBoss AS is the most used Java application server on the market meeting high standards of reliability, efficiency, and robustness and is used to build powerful and secure Java EE applications. It supports the most important areas of Java Enterprise programming including EJB 3.0, dependency injection, web services, the security framework, and more. Getting started with JBoss application server development can be challenging; however, with the right approach and guidance, you can easily master it and this book promises that.
Written in an easy-to-read style, this book will take you from the basics of JBoss AS-such as installing core components and plug-ins-to the skills that will make you a JBoss developer to be reckoned with, covering advanced topics such as developing applications with JBoss Messaging service, JBoss web services, clustered applications, and more.
You will learn the necessary steps to install a suitable environment for developing enterprise applications on JBoss AS. Then, your journey will continue through the heart of the application server, explaining how to customize each service for optimal usage. You will learn how to design Enterprise applications using Eclipse and JBoss plug-ins. You will then learn how to enable distributed communication using JMS. Storing and retrieving objects will be made easier using Hibernate. The core section of the book will take you into the programming arena with tested, real-world examples. The example programs have been carefully crafted to be easy to understand and useful as starting points for your applications.
This book will kick-start your productivity and help you to master JBoss AS development. The author's experience with JBoss enables him to share insights on JBoss AS development, in a clear and friendly way. By the end of the book, you will have the confidence to apply all the newest programming techniques to your JBoss applications.
This practical guide will show you how to gain hands-on experience rapidly on Java EE development using JBoss AS with easy-to-understand and practical programming examples
ApproachThis book follows a tutorial-based approach starting with simple examples, which are enriched in the following chapters as new topics are introduced. Each chapter provides clear instructions and detailed screenshots, as the user approaches a new facet of the development environment. Most complex topics have been explained using practical examples, which will help you to master JBoss AS development.
Who this book is forIf you are a Java architect or developer who wants to get the most out of the latest release of the JBoss application server or a JBoss administrator who wants a clear and simple reference for JBoss services, this book is for you. You are not expected to have accumulated experience on the application server though you must know the basic concepts of Java EE.
Francesco Marchioni
Francesco Marchioni is a Red Hat Certified JBoss Administrator (RHCJA) and a Sun Certified enterprise architect working as a freelancer in Rome, Italy. He started learning Java in 1997, and since then, he has followed the path to the newest application program interfaces released by Sun. In 2000, he joined the JBoss community, when the application server was running the release 2.X. He has spent many years as a software consultant, wherein he envisioned many successful software migrations from vendor platforms to open source products such as JBoss AS, fulfilling the tight budget requirements of current times. Over the past 5 years, he has been authoring technical articles for OReilly Media and running an IT portal focused on JBoss products (http://www.mastertheboss.com). In December 2009, he published JBoss AS 5 Development, which describes how to create and deploy Java Enterprise applications on JBoss AS (http://www.packtpub.com/jboss-as-5-development/book). In December 2010, he published his second title, JBoss AS 5 Performance Tuning, which describes how to deliver fast and efficient applications on JBoss AS (http://www.packtpub.com/jboss-5-performance-tuning/book). In December 2011, he published yet another title, JBoss AS 7 Configuration, Deployment, and Administration, which covers all the aspects of the newest application server release (http://www.packtpub.com/jboss-as-7-configuration-deploymentadministration/book). In June 2013, he authored a new title, JBoss AS 7 Development, which focuses on developing Java EE 6 API applications on JBoss AS 7 (https://www.packtpub.com/application-development/jboss-7-development).
Read more from Francesco Marchioni
Hands-On Cloud-Native Applications with Java and Quarkus: Build high performance, Kubernetes-native Java serverless applications Rating: 0 out of 5 stars0 ratingsMastering JBoss Enterprise Application Platform 7 Rating: 0 out of 5 stars0 ratingsJBoss AS 7 Development Rating: 0 out of 5 stars0 ratingsJBoss AS 5 Performance Tuning: Build faster, more efficient enterprise Java applications Rating: 0 out of 5 stars0 ratingsJava EE 7 Development with WildFly Rating: 0 out of 5 stars0 ratings
Related to JBoss AS 5 Development
Related ebooks
JBoss AS 5 Performance Tuning Rating: 0 out of 5 stars0 ratingsWebSphere Application Server 7.0 Administration Guide Rating: 0 out of 5 stars0 ratingsIBM WebSphere Application Server 8.0 Administration Guide Rating: 0 out of 5 stars0 ratingsApache CXF Web Service Development Rating: 0 out of 5 stars0 ratingsIBM WebSphere Application Server v7.0 Security: For IBM WebSphere users, this is the complete guide to securing your applications with Java EE and JAAS security standards. From a far-ranging overview to the fundamentals of data encryption, all the essentials are here. Rating: 0 out of 5 stars0 ratingsJBoss Tools 3 Developers Guide Rating: 0 out of 5 stars0 ratingsJava EE 8 Development with Eclipse: Develop, test, and troubleshoot Java Enterprise applications rapidly with Eclipse Rating: 0 out of 5 stars0 ratingsJBoss: Developer's Guide: A complete guide to the JBoss ecosystem Rating: 0 out of 5 stars0 ratingsGlassFish Administration Rating: 0 out of 5 stars0 ratingsSpring MVC Blueprints Rating: 0 out of 5 stars0 ratingsJBoss Portal Server Development: Create dynamic, feature-rich, and robust enterprise portal applications Rating: 5 out of 5 stars5/5Oracle SOA Suite 11g Administrator's Handbook Rating: 0 out of 5 stars0 ratingsWildFly Configuration, Deployment, and Administration - Second Edition Rating: 0 out of 5 stars0 ratingsMicrosoft Application Virtualization Advanced Guide Rating: 0 out of 5 stars0 ratingsEnterprise Application Development with Ext JS and Spring Rating: 0 out of 5 stars0 ratingsMastering GeoServer Rating: 0 out of 5 stars0 ratingsASP.NET MVC 4 Mobile App Development Rating: 0 out of 5 stars0 ratingsBuilding Web APIs with ASP.NET Core Rating: 0 out of 5 stars0 ratingsSpring MVC: Designing Real-World Web Applications Rating: 0 out of 5 stars0 ratingsAlfresco Developer Guide Rating: 0 out of 5 stars0 ratingsIBM WebSphere Portal 8: Web Experience Factory and the Cloud Rating: 0 out of 5 stars0 ratingsOracle SOA Suite 12c Administrator's Guide Rating: 0 out of 5 stars0 ratingsNode.js Web Development - Third Edition Rating: 0 out of 5 stars0 ratingsVisual SourceSafe 2005 Software Configuration Management in Practice Rating: 0 out of 5 stars0 ratingsMicrosoft BizTalk Server 2010 Patterns Rating: 2 out of 5 stars2/5Digital Java EE 7 Web Application Development Rating: 4 out of 5 stars4/5WCF Multi-layer Services Development with Entity Framework - Fourth Edition Rating: 0 out of 5 stars0 ratings
Programming For You
Mastering C# and .NET Framework Rating: 5 out of 5 stars5/5Python for Finance Cookbook: Over 50 recipes for applying modern Python libraries to financial data analysis Rating: 0 out of 5 stars0 ratingsLearn JavaScript in 24 Hours Rating: 3 out of 5 stars3/5Python for Beginners: A Crash Course to Learn Python Programming in 1 Week Rating: 0 out of 5 stars0 ratingsPython: Learn Python in 24 Hours Rating: 4 out of 5 stars4/5Coding All-in-One For Dummies Rating: 4 out of 5 stars4/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5Python Programming : How to Code Python Fast In Just 24 Hours With 7 Simple Steps Rating: 4 out of 5 stars4/5Angular in Action Rating: 0 out of 5 stars0 ratingsLearn Algorithmic Trading: Build and deploy algorithmic trading systems and strategies using Python and advanced data analysis Rating: 0 out of 5 stars0 ratingsDeep Learning For Dummies Rating: 0 out of 5 stars0 ratingsPython: For Beginners A Crash Course Guide To Learn Python in 1 Week Rating: 4 out of 5 stars4/5HTML, CSS, & JavaScript All-in-One For Dummies Rating: 0 out of 5 stars0 ratingsGrokking Simplicity: Taming complex software with functional thinking Rating: 4 out of 5 stars4/5Learn SAP Basis in 24 Hours Rating: 5 out of 5 stars5/5Expert Delphi Rating: 5 out of 5 stars5/5Modern C++ Programming Cookbook Rating: 5 out of 5 stars5/550 Recipes for Programming Angular Rating: 4 out of 5 stars4/5Python Crash Course: A Hands-On Introduction to Programming Rating: 0 out of 5 stars0 ratingsPython Data Structures and Algorithms Rating: 5 out of 5 stars5/5TensorFlow in 1 Day: Make your own Neural Network Rating: 4 out of 5 stars4/5PYTHON: Practical Python Programming For Beginners & Experts With Hands-on Project Rating: 5 out of 5 stars5/5Basic Exercises for Competitive Programming: Python Rating: 0 out of 5 stars0 ratingsNarrative Design for Indies: Getting Started Rating: 4 out of 5 stars4/5HTML & CSS: Learn the Fundaments in 7 Days Rating: 4 out of 5 stars4/5Algorithms For Dummies Rating: 4 out of 5 stars4/5Javascript For Beginners: Your Guide For Learning Javascript Programming in 24 Hours Rating: 3 out of 5 stars3/5
Reviews for JBoss AS 5 Development
0 ratings0 reviews
Book preview
JBoss AS 5 Development - Francesco Marchioni
Table of Contents
JBoss AS 5 Development
Credits
About the Author
About the Reviewers
Preface
What this book covers
Who this book is for
Conventions
Reader feedback
Customer support
Errata
Piracy
Questions
1. Installing Core Components
Prologue
What you will get in this book
JBoss big bang
Introduction
Installing the Java environment
Installing JBoss AS 5
Starting up JBoss AS
Stopping JBoss
Stopping JBoss on a remote machine
Installing Eclipse
Plugins: The heart of Eclipse
Installing JBoss Tools plugins
Installing JBoss Tools plugins manually
Connecting Eclipse with JBoss
Summary
2. What's New in JBoss AS 5?
Application server features
The core modules of JBoss AS 5
Cutting edge EJB container
The new messaging provider
Rock solid transaction manager
Enhanced web container
JBoss Web Services 3.0
Improved clustering support
The application server structure
The next generation application server
From JMX to the Microcontainer
The new library configuration
JBoss AS 5 server configurations
The standard
configuration
The web
configuration
The former server configurations
Creating a custom server configuration
The starting point: JBoss AS service map
Custom configuration sample: Adding JMS to the web configuration
JBoss virtual file system
Summary
3. Customizing JBoss AS Services
How to monitor JBoss AS services
The JMX console
An example: Using the JMX console to display the JNDI tree
The admin console
The twiddle utility
JBoss AS thread pool
Application server thread pool anatomy
How many threads for your applications?
Analyze what your threads are doing
Configuring logging services
Appenders
Console file appender
Changing the configuration at runtime
File appenders
Rolling the file by size
Other appenders
Layout of logs
Logging categories
Configuring your own logger
Managing logs through JMX agents
Configuring the connection to the database
Configuring a datasource in JBoss AS
Additional datasource properties
Setting up a new datasource
Gathering connection pool statistics
Managing datasources from the admin console
Using statistics to tune the connection pool
Deploying datasources at application level
High availability datasources
Clustered RDBMS
Connecting from a remote client
Configuring the transaction service
Preserving data integrity
Global and local transactions
Configuring JBoss transactions
Monitoring transactions
Summary
4. Developing EJB 3 Session Beans
Java EE made easier
Developing Enterprise JavaBeans
Developing Session Beans
Stateless Session Beans
Life cycle of a Stateless Session Bean
Setting up a simple example
Deploying your application
Creating a test client
Adding interceptors to your Bean
Stateful Session Beans
Stateful Bean life cycle
Developing a simple Stateful Session Bean
Configuring the EJB container
Configuring Stateless Session Bean pool size
Specializing the configuration
Configuring the Stateful Session Bean cache
How to disable Stateful Bean passivation
Summary
5. Developing JPA Entities
Data persistence meets a standard
Working with JPA
Creating a sample application
Setting up the database
Rolling the EJB project
Configuring the database connection
Generating entities
Reverse engineering aftermath
Configuring persistence
Creating a Session Bean client
Creating a test client for our AppStore
Summary
6. Creating a Web Application
Developing web layout
Installing JSF on JBoss AS
Setting up navigation rules
Adding a JSF managed bean
Setting up the view
Assembling and deploying the application
Running the store
Configuring JBoss Web Server
Customizing connectors
The new Apache Portable Runtime connector
Installing the APR connector
Configuring contexts
Configuring virtual hosts
Configuring HTTP logs
Tuning advice
Disable DNS lookup
Choose the right HTTP connector
Set the correct size for your thread pool
Monitoring your thread pool
Summary
7. Developing Applications with JBoss Messaging Service
Short introduction to JMS
The building blocks of JMS
The new JBoss Messaging system
Configuring connection factories
Configuring JMS destinations
Inspecting destination attributes
Advanced message configuration
Scheduled delivery
Developing JMS applications
Message-driven beans
Configuring message-driven beans
Creating a sample application
Creating MDB singletons
Message-driven POJOs
Advanced JBoss Messaging
JBoss Messaging bridge
Adding a remote JMS provider
Configuring the persistence service
Securing destinations
MDB access control
Summary
8. Developing Applications with JBoss and Hibernate
Introducing Hibernate
Creating a Hibernate application
Setting up the database schema
A new Eclipse project
Reversing your schema into Java classes
Adding Hibernate configuration to your project
Adding a web client to your project
Packaging and deploying the application
Using the wizard to generate EJB 3
Hibernate and EJB: Friends or opponents?
Using Hibernate with EJB
Injecting key Hibernate objects
Summary
9. Managing JBoss AS
Introducing Java Management Extension
Developing MBeans
A simple MBean
Testing your MBean from the JMX console
Testing your application programmatically
MBeans dependency
Sending MBeans notifications
Receiving heartbeat notifications
Sending your own notifications
Service POJOs
Creating a web test client
Exposing your service as an EJB
Service POJO dependency
JBoss AS Administration Console
Managing applications
Deploying/undeploying applications
Updating an application
Starting/stopping/restarting an application
Administering resources
Adding a new resource
Managing resources
Metrics
Summary
10. Developing Applications with JBoss Web Services
Web Service concepts
Strategies for building up Web Services
JBoss Web Services stack
A brief look at the JAX WS architecture
Coding Web Services with JBossWS
Developing a POJO Web Service
Inspecting the Web Service from the console
Using JBossWS tools
External Web Service clients
Exposing EJB as Web Services
Handling exceptions in Web Services
Generating a test client
Injecting Web Services
Web Service Handler chains
Summary
11. Clustering JBoss AS
Cluster basics
Introducing JBoss AS cluster
JBoss AS clustering architecture
Smart proxies
External load balancer
JBoss AS 5 cluster configuration
Starting JBoss AS in cluster mode
Running cluster nodes on separate machines
Running cluster nodes on the same machine
Running multiple clusters on the same network
JBoss AS clustered services
JBoss Cache (JBC)
Cache modes
Cache configuration
Configuring HTTP cache management
Configuring EJB 3.0 Stateful Session Bean cache
Configuring entity caching
JBoss cache and concurrency
The HAPartition service
Exploring HA singletons
The HA-JNDI service
Accessing HA-JNDI
HA-JNDI configuration
Clustering web applications
Configuring HTTP replication
HttpSession passivation/activation
Configuring load balancing
JMS clustering
Summary
12. Developing a Clustered Application
Clustering Stateless Session Beans
Clustering Stateful Session Beans
Deploying a clustered SFSB
Testing the clustered SFSB
Programmatic replication of the session
Clustering entities
Revisiting the AppStore example
Inside the second-level cache
Evicting entities from the cache
General guidelines for a good cache
Clustering web applications
Testing HTTP session replication
Summary
13. JBoss AS Security
Approaching Java Security API
The JAAS security model
Introducing JBossSX
Securing the JMX console
Dynamic login configuration
Stacked login configuration
Logging and auditing
Securing the transport layer
Enabling the Secure Socket Layer on JBoss AS
Certificate management tools
Securing the HTTP communication with a self-signed certificate
Securing the HTTP communication with a certificate signed by a CA
Securing the RMI transport
Adding a client truststore
Summary
14. Securing JBoss AS Applications
Securing the AppStore application
HTTP role authentication
Encrypting passwords
EJB role authorization
Java EE programmatic security
Writing secure Java SE clients
Securing applications at transport level
Running the AppStore with HTTPS
Securing the RMI-IIOP transport: SSL BlackJack
Securing Web Services
Web Services authorization
Web Services encryption
Client and server configuration files
Encrypting the POJOWebService
Securing the Web Service
Securing the client
Running the example
Signing SOAP messages
Debugging SOAP messages
Summary
Index
JBoss AS 5 Development
Francesco Marchioni
JBoss AS 5 Development
Copyright © 2009 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, Packt Publishing, nor its dealers or distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: December 2009
Production Reference: 1091209
Published by Packt Publishing Ltd.
32 Lincoln Road
Olton
Birmingham, B27 6PA, UK.
ISBN 978-1-847196-82-8
www.packtpub.com
Cover Image by Vinayak Chittar (<vinayak.chittar@gmail.com>)
Credits
Author
Francesco Marchioni
Reviewers
Edem Morny
Peter Johnson
Acquisition Editor
Sarah Cullington
Development Editor
Amey Kanse
Technical Editors
Gaurav Datar
Smita Solanki
Indexer
Hemangini Bari
Editorial Team Leader
Abhijeet Deobhakta
Project Team Leader
Lata Basantani
Project Coordinator
Joel Goveya
Proofreader
Chris Smith
Graphics
Nilesh R. Mohite
Production Coordinator
Aparna Bhagat
Cover Work
Aparna Bhagat
About the Author
Francesco Marchioni is a Sun Certified Enterprise architect employed by an Italian company based in Rome. He started learning Java in 1997 and since then he has followed the path to the newest application program interfaces released by Sun. He joined the JBoss community in 2000, when the application server was running release 2.X.
He has spent many years as a software consultant, where he has envisioned many successful software migrations from vendor platforms to open source products such as JBoss AS, fulfilling the tight budget requirements of current times.
In the past five years, he has authored technical articles for O'Reilly Media and is running an IT portal focused on JBoss products (http://www.mastertheboss.com).
I'd like to thank Packt Publishing for giving me this unique opportunity to write a book about a great product like JBoss. All the staff I have worked with has been very cooperative at giving their time in the arduous publishing process. I'd also like to thank the external reviewers Peter Johnson and Edem Morny who have offered their professional expertise for many parts of this book. And last but not the least, I want to pay my tribute to my family, my father in particular who has transmitted me the virus of programming when I was just a boy, my wife Linda who was so patient with my late nights and with my missing housework, and my 2 years old baby Alessandro who hasn't actually helped in writing this book but has been the inspiration of it.
About the Reviewers
Edem Morny has been involved in Enterprise Java technologies since he got introduced to Java in 2005, using tools and technologies encompassing both the standard Java EE stack and non-standard ones such as Hibernate and Spring. His experience with JBoss AS has also included porting clustered, fault-tolerant deployments of applications, from proprietary application servers to the open source alternative.
He has been an active promoter of Java EE, speaking at workshops and seminars on a national scale in Ghana. He is the cofounder of Ghana's first Java User Group, JAccra (http://groups.google.com/group/jaccra).
He is a senior developer at the application development center in Accra, Ghana, of an international biometric security solutions company, leading the development of Biocryptic Identity Management Systems for the global market.
Edem was a technical reviewer of JBoss Tools 3 Developer Guide, published by Packt Publishing in the year 2009. You'll find him blogging at http://edemmorny.wordpress.com.
Peter Johnson started his computer career in August, 1980, working for Burroughs, programming mainframes in COBOL and ALGOL. He started working with Java in 1998, and was a 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 the chief architect of a team that does performance analysis of Java applications on large scale Intel-based machines (8 to 32 CPUs), and evaluates various open source software for Enterprise readiness.
In addition, Peter is a JBoss committer and is the coauthor of the book JBoss In Action, published by Manning. Peter often speaks on Java performance and various open source topics at industry conferences such as JBoss World and the annual Computer Measurement Group International Conference.
Preface
The JBoss Application Server is a Java EE-certified platform for developing and deploying Java Enterprise applications. JBoss Application Server provides the full range of J2EE 1.5 features as well as extended Enterprise services including clustering, caching, and persistence. This book will show Java EE developers how to develop their applications using the JBoss Application Server. It covers topics such as:
Setting up a development environment
Customization
Java EE programming modules
Clustering
Security
All these features will be explored by developing sample and intuitive applications built using the friendly interface of Eclipse and JBoss Tools.
What this book covers
Chapter 1: Installing Core Components covers the installation of the key components that will be needed throughout the rest of the book. The installation process will be completed by using intuitive wizards that will lead even inexperienced users through it.
Chapter 2: What's New in JBoss AS 5.0 introduces the reader to the most significant changes brought by release 5.0 of the application server. The new server directory tree is analyzed in detail and possible variants in the server configuration are discussed in the latter part of this chapter.
Chapter 3: Customizing JBoss Services discusses the core configuration of the application server. The highlights of it include an introduction to JBoss AS monitoring services, the inner details about JBoss thread pool, how to configure logging services, and a detailed description of the transaction and Datasource service.
Chapter 4: Developing EJB 3 Session Bean introduces the reader to some concrete Java EE programming examples developed on JBoss AS 5. The focus of this chapter is on EJB 3 session Beans, including a section about their configuration for optimal results.
Chapter 5: Developing JPA Entities covers the development of an example based on the Java Persistence API (JPA). Here, we introduce an enterprise application named the Appstore, which will be a central theme of this book.
Chapter 6: Creating a Web Application is about developing and configuring web applications on JBoss AS 5.0 using the JSF cutting-edge technology. In the first part of this chapter we will enhance the Appstore Enterpirse application by adding a web layer to it. In the latter part, we explain in detail how to properly configure JBoss Web Server.
Chapter 7: Developing Applications with JBoss Messaging Service discusses JBoss Messaging provider by giving a short introduction to the new messaging system. The chapter then helps us set up some proof of concept programming examples.
Chapter 8: Developing Applications with JBoss and Hibernate covers the de facto standard object relational mapping tool, Hibernate, showing how to quickly set up a Hibernate project using the facilities provided by the JBoss tools interface.
Chapter 9: Managing JBoss AS covers the Java Management Extension (JMX), which still plays a vital role in the application server infrastructure. The chapter includes many examples that show how to write traditional MBeans services and the new POJO Services.
Chapter 10: Developing Applications with JBoss Web Services focuses on the JBoss Web Service implementation, JBossWS, showing how to create, deploy, and test Web Services on JBoss AS along with some advanced concepts such as Handler chains and SOAP debugging.
Chapter 11: Clustering JBoss AS covers the facts about JBoss AS clustering configuration, moving from cluster basics to detailed configuration of the individual services of the application server.
Chapter 12: Developing a Clustered Application continues the journey in the clustering arena by adding some concrete examples based on the abstract concepts covered in the earlier chapter.
Chapter 13: JBoss AS Security provides a systematic guide to JBoss security framework and the cryptographic interfaces available in the Java EE framework. This supplies the basis for concrete examples, which are delivered in the next chapter.
Chapter 14: Securing JBoss AS Applications continues the in-depth exploration of the JBoss security framework, adding concrete programming examples applied on the EJB and Web Services technologies.
Who this book is for
If you are a Java architect or developer who wants to get the most out of the latest release of the JBoss application server or a JBoss administrator who wants a clear and simple reference for JBoss services, this book is for you. You are not expected to have accumulated experience on the application server though you must know the basic concepts of Java EE.
Conventions
In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.
Code words in text are shown as follows: Since release 5.1.0 of the application server, the admin console is bundled as a web application in the deploy folder of JBoss AS.
A block of code will be set as follows:
name=jboss.system:service=ThreadPool
>
When we wish to draw your attention to a particular part of a code block, the relevant lines or items will be shown in bold sometimes with numbers in square brackets referring to notes in the text:
an>
Any command-line input or output is written as follows:
twiddle -s localhost invoke jboss.system:type=ServerInfo
listThreadCpuUtilization > threadCpu.txt
New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in our text like this: In the left frame expand the Resources | Datasources leaf and choose the suitable transaction option.
Note
Warnings or important notes appear in a box like this.
Tip
Tips and tricks appear like this.
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply drop an email to <feedback@packtpub.com>, and mention the book title in the subject of your message.
If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or email
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
Note
Downloading the example code for the book
Visit http://www.packtpub.com/files/code/6828_Code.zip to directly download the example code.
The downloadable files contain instructions on how to use them.
Errata
Although we have taken every care to ensure the accuracy of our contents, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in text or code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration, and help us to improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the let us know link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata added to any list of existing errata. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.
Piracy
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <copyright@packtpub.com> with a link to the suspected pirated material.
We appreciate your help in protecting our authors, and our ability to bring you valuable content.
Questions
You can contact us at <questions@packtpub.com> if you are having a problem with any aspect of the book, and we will do our best to address it.
Chapter 1. Installing Core Components
Prologue
From: Acme Head Offices
To: Francesco Marchioni
Hi Francesco,
Can you meet at 4 PM in the boardroom? We are going to interview a few guys for the new JBoss Enterprise project.
Regards,
Monty Burns
JBoss Application Server has been around since the beginning of the new millennium and, in personal resumes, it is common to find people who have acquired some experience on it.
Before every job interview, I have the expectation that high caliber Java/Java EE candidates surely know the core concepts of JBoss AS. Often, companies don't consider hiring just the best techie guy, but a well-rounded profile with a situation-action-result
mind.
One thing I personally like to ask to identify smart developers is: Why have you chosen to learn JBoss and not XYZ? How does it differentiate from the competitors? The most habitual answer is: JBoss is free, so I chose to learn Java EE on this platform. Although there is some truth in this answer, I think it's a partial truth and the concept needs to be elaborated.
First, let's define what is free. Today there's a common misconception of open source products being like free lunch
. They can be so for a student who's learning these technologies, but for the real world, open source means you don't pay a license fee to develop/roll in production certain software.
This obviously doesn't mean that the software hasn't got a cost. Moreover, if you don't want to risk breaking your service level agreement, you usually sign a contract with the owner of the open source software so that it guarantees quick and decisive support.
From the financial point of view, this is the first important difference with a commercial product. If you start a project, running a product such as JBoss AS, you don't have an immediate entrance fee. You can even dispense with commercial assistance if you are confident that your technicians will be able to solve any issue. Whatever you choose, this policy is much more flexible than a commercial contract, which requires an immediate financial commitment.
That's better than simply saying: I like JBoss because it's free.
The second and, in my opinion, the most important reason is the worldwide spread of the product. Today JBoss is the most used application server and it has been not only built with the collaborative efforts of many developers around the world, but also with simple contributions of users who request new features. This boils down to the actual nature of the success of JBoss. The real driving force of this product is its community of users, while vendor products are usually designed around commercial or marketing schemas.
As an example of this, you can see that JBoss Application Server is a Java EE compatible server, but you can freely add or remove modules from the application server, thus creating a customized product for your specific needs. It is the flexibility and willingness to adapt that has brought JBoss AS this far, and it will be this trait that will drive the application server full speed into the future.
What you will get in this book
This book is an intense guide to creating professional Java EE applications with JBoss AS 5.0. Packed with example code and written in a friendly, earthy style, this book will act as a handy guide to take you from the basics to the skills that will make you a JBoss developer to be reckoned with.
We think that studying good code samples is one of the best ways to learn, so we included as many as we could. We also wanted this book to be a quick reference to solve most common issues—a book you can have on your desk and turn to when you have a doubt.
JBoss big bang
JBoss AS is an open source Java EE-based application server. The project's first milestone dates back to early 1999, when Marc Fleury developed an open source product named JBoss that was a simple EJB 1.0 container. Since then, the project has been incorporated in a company named JBoss Group. In April 2006 the company was acquired by Red Hat Inc., which started providing professional services to the product. As a matter of fact, you now have two main references for JBoss products—http://www.jboss.org, which is the community of developers where you can freely download products and join forums, and the commercial site http://www.jboss.com, which is targeted at commercial support for the product.
Introduction
This is where our journey begins. In this chapter, we'll learn how to set up our environment for developing applications on JBoss AS correctly. Installation of the components is not particularly tricky, but it needs a few steps to be performed and quite a lot of Kbytes to be downloaded.
This is our checklist:
Install the appropriate Java Development Kit (JDK) for running JBoss AS
Install JBoss AS 5.0
Install the Eclipse development environment
Install the JBoss Tools plugins needed for developing applications
The products listed in this chapter are the latest versions at the time of writing and we diligently updated it at every new release. Don't worry if a new stable release of these products is released in the next months; all you have to do is adapt the chapter instructions to the newest file names.
Installing the Java environment
JBoss is a pure Java application server, so as you might imagine it needs a virtual machine for the Java Platform to run on.
At the time of writing, JBoss AS 5 is distributed in two flavors, one that is suited for Java 1.5 and another version that has been specifically designed for Java 1.6.
The choice of Java Virtual Machine (JVM) is yours otherwise, but we do recommend considering the Java 1.6, that has just undergone the 16th update at the time of writing. Most benchmarks available on the Internet exhibit a roughly 40 percent performance improvement by upgrading from Java 1.5 to Java 1.6. Additionally, Java SE 5.0 reached its End of Service Life (EOSL) on November 3, 2009, which is the date of the final publicly available update of version 5.0. So you are highly encouraged to design your applications with Java 1.6.
Note
Java 1.6 has enhanced performance in many areas of the platform. Improvements include synchronization, performance optimizations, compiler performance optimizations, the new Parallel Compaction Collector, better ergonomics for the Concurrent Low Pause Collector, and application startup performance.
(http://java.sun.com/performance/reference/whitepapers/6_performance.html)
So let's move on to the Sun download page: http://java.sun.com/javase/downloads/index.jsp.
Choose to download the latest JDK/JRE, which is for JDK 1.6 Update 16.
Tip
Is JRE enough ?
Yes! JBoss 5 ships with a set of libraries called Eclipse Java development tools (JDT) that allow dynamic compilation of classes at runtime. However, we still suggest you to download the full JDK installation, in case you need to compile your classes with plain javac anywhere else.
Once the download is complete, run the executable file to start the installation.
jdk-6-windows-i586.exe # Windows sh jdk-6u12-linux-i586.bin # Linux
If you are installing on a Linux/Unix box, you can safely accept all the defaults given to you by the setup wizard. Windows users should stay away from the default C:\Program Files that leads to some issues when you are referencing the core libraries. An installation path such as C:\Software\Java or simply C:\Java is a better alternative.
When the installation is complete, we need to update a couple of settings on the computer so that it can interact with Java.
The most important setting is JAVA_HOME that is directly referenced by JBoss startup script.
Windows XP/2000 users should right-click on My Computer and select Properties from the context menu. On the Advanced tab, click the Environment Variables button. Then, in the System variables box click New. Give the new variable a name of JAVA_HOME, and a value of the path to your JDK installation, probably something like C:\Java\jdk1.6.0_16.
Tip
For Windows Vista users
Because of increased security in Windows Vista, standard users must have User Account Control (UAC) turned on to change environment variables and the change must be completed through User Accounts. In the User Accounts window, under Tasks, select Change my environment variables. Use the New, Edit, or Delete buttons to add, change,