Mastering JBoss Enterprise Application Platform 7 - Francesco Marchioni - E-Book

Mastering JBoss Enterprise Application Platform 7 E-Book

Francesco Marchioni

0,0
46,79 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

Create modular scalable enterprise-grade applications with JBoss Enterprise Application Platform 7

About This Book

  • Leverage the power of JBoss EAP 7 along with Java EE 7 to create professional enterprise grade applications.
  • Get you applications cloud ready and make them highly scalable using this advanced guide.
  • Become a pro Java Developer and move ahead of the crowd with this advanced practical guide.

Who This Book Is For

The ideal target audience for this book is Java System Administrators who already have some experience with JBoss EAP and who now want explore in depth creating Enterprise grade apps with the latest JBoss EAP version.

What You Will Learn

  • Configure services using the Command Line Interface
  • Deliver fault tolerant server configurations
  • Harden the application server with advanced techniques
  • Expand the application server's horizon with tools such as like Docker/OpenShift
  • Create enterprise ready configurations using clustering techniques.
  • Deliver advanced security solutions and learn how to troubleshoot common network/performance issues

In Detail

The JBoss Enterprise Application Platform (EAP) has been one of the most popular tools for Java developers to create modular, cloud-ready, and modern applications. It has achieved a reputation for architectural excellence and technical savvy, making it a solid and efficient environment for delivering your applications.

The book will first introduce application server configuration and the management instruments that can be used to control the application server. Next, the focus will shift to enterprise solutions such as clustering, load balancing, and data caching; this will be the core of the book. We will also discuss services provided by the application server, such as database connectivity and logging. We focus on real-world example configurations and how to avoid common mistakes. Finally, we will implement the knowledge gained so far in terms of Docker containers and cloud availability using RedHat's OpenShift.

Style and approach

If you are a Java developer who wants to level-up to modern day Java web development with the latest Java EE 7 and JBoss EAP 7, this book is the ideal solution for you. It addresses (in a clear and simple way) proof-of-concept scenarios such as clustering and cloud and container configurations, and explains how to solve common issues.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 359

Veröffentlichungsjahr: 2016

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Mastering JBoss Enterprise Application Platform 7
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Installation and Configuration
What's new in EAP 7?
Installing EAP 7
Installing from the ZIP file
Installing EAP from RPM
Installing from the JAR installer
Installing from the source
Other installation options
Starting the application server
Stopping the application server
Basic server administration
EAP 7 basic configuration
Standalone configuration
Domain configuration
Application server core building blocks
Extensions
Paths
Interfaces
Socket bindings and socket binding groups
System properties
Profiles and subsystems
Summary
2. The CLI Management Tool
Connecting to the CLI
Using the CLI
Basic operations
Managing server state
Deploying and undeploying an application using CLI
Creating a configuration snapshot
Features of the CLI
Batch mode
Commands in batch mode
Scripting in the CLI
Using the CLI in offline mode
Using the CLI in graphical mode
Summary
3. Managing EAP in Domain Mode
Domain mode breakdown
Domain physical components
Domain logical components
Handy domain properties
Electing the domain controller
Creating an advanced domain
Building up your domain
Configuring host controllers
Connecting other host controllers
Tweaking the domain settings
Domain controller failover
Basic solution – building a watchdog procedure
Using domain start up options to allow host controller restart
Using domain discovery to elect a new domain controller
Using a centralized store for your server configurations
Additional EAP 7 features
Connecting EAP 6 host controllers to an EAP 7 domain controller
Hierarchical profiles
Profile cloning
Summary
4. Deploying Applications
Overview of deployments
Deployment in standalone mode
Automatic deployment
Deployment triggered by the user
Deploying using the CLI
Deploying using the web console
Deployment in domain mode
Deployment using the CLI
Deployment using the web console
Advanced deployment strategies
Deployment overlays
Summary
5. Load Balancing
The need for balancing
Load balancing with mod_cluster
Configuring EAP 7 as load balancer
Configuring the frontend server
Advantages of an all-in-one solution
Configuring mod_cluster with Apache
Installing mod_cluster on the Apache web server
Testing mod_cluster
Troubleshooting mod_cluster
Security checks
Network checking
Network checks for non-Linux machines
Configuring mod_cluster to use TCP transport
Determining the optimal load configuration between Apache and JBoss
Configuring balancing groups
Why use balancing groups?
Configuring mod_cluster balancing factors
Adding custom mod_cluster metrics
Using other balancing solutions
Configuring mod_jk
Configuring mod_proxy
Configuring Nginx load balancer
Summary
6. Clustering EAP 7
Clustering overview and misconceptions
Clustering in standalone mode
Testing in standalone mode
Clustering from a network point of view
Clustering in domain mode
Server-group configuration
Testing in domain mode
Advanced topics
Clustering using TCP
EJBs in a clustered environment
Testing clustered EJB
Summary
7. Logging
The basics of logging
Default log file locations
Configuring handlers
Console handler
Periodic log handlers
Size handlers
Combining size and periodic log files
Adding asynchronous behavior
Custom handlers
JBoss SyslogHandler
Filtering logs
Configuring loggers
Defining new loggers
Managing your application logging
Per-deployment logging
Logging profiles
Reading logs with management interfaces
Reading logs from the CLI
Streaming logging through HTTP
Building a centralized logging system
Summary
8. Configuring Database Connectivity
Introduction to datasources
Datasource overview
Prerequisites
Adding a JDBC 4 driver module
Configuring a JDBC 4-compliant driver
Defining a new datasource
Connection pool for a datasource
Flushing a pool's connections
Validating pool's connection
Defining an XA-datasource
Connection pool for an XA-datasource
Difference between XA and non-XA datasource
Hardening datasource configuration
Password encryption
Password protection using the vault
Summary
9. Configuring EAP 7 for Java EE Applications
Configuring the EJB container
Configuring the stateless EJB pool
Configuring the message driven bean pool
Configuring the stateful EJB cache
Controlling the amount of stateful beans in the cache
Configuring the web server
Undertow core server configuration
Configuring Undertow connectors
Configuring the pool of threads used by Undertow
Migrating from web configurations
Migrating Valve components
Configuring Undertow to serve static content
Undertow servlet container
Monitoring your applications
Using JConsole to display graphical attributes
Data mining using the ELK stack
Using Byteman to trace your application
Summary
10. Messaging Administration
Introduction to Artemis MQ
Configuring broker transport
Configuring persistence
Configuring destinations
Routing messages to other destinations
Diverting messages to other destinations
Creating a bridge between two ActiveMQ Artemis servers
ActiveMQ Artemis source configuration
ActiveMQ Artemis target configuration
Bridging messages to another JMS broker
Clustering
Configuring server discovery
Broadcast groups
Discovery groups
Configuring high availability
HA with shared-store
Restoring the master node
HA with data replication
Shared-store versus replication
Summary
11. Securing the Application Server
Creating security domains
Internal based login modules
External based login modules
Database login module
Troubleshooting security domains
Hardening the database login modules
Creating a Kerberos security domain
Basic Kerberos configuration
Running the Kerberos server
Testing the Kerberos login against management interfaces
Using Kerberos to provide SSO
Securing the management interfaces with LDAP
Setting up LDAP authentication
HA LDAP
Configuring RBAC
Mapping individual users
Mapping groups to roles
Mapping groups with property files
Mapping groups with LDAP
Scoped roles
Generating certificates
Creating an SSL realm
Securing the management interfaces
Summary
12. New Security Features of EAP 7
EAP 7 new security model
Introducing elytron
Elytron building blocks
An overview of the elytron subsystem
Creating a FileSystem security realm
Developing a JDBC realm
Developing an LDAP realm
Introducing Red Hat SSO
Installing Red Hat SSO server
Creating a new realm
Configuring client applications
Installing the client template on the server
Summary
13. Using EAP 7 with Docker
Getting to grips with Docker
Basic components of containers
Installing Docker
Running your first container
Creating your Docker images
Building our image
Inspecting the server logs
Managing the server storage
Mounting a volume from the host machine
Troubleshooting mounting volumes from the host machine
Using a data container
Managing multiple containers
Using Docker compose
Composing EAP 7 with a Database
Composing a cluster of EAP 7 nodes
Summary
14. Running EAP 7 on the Cloud Using OpenShift
Introducing OpenShift
OpenShift Online
Developing and deploying your first OpenShift application in the cloud
Summary

Mastering JBoss Enterprise Application Platform 7

Mastering JBoss Enterprise Application Platform 7

Copyright © 2016 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 authors, nor Packt Publishing, and its dealers and 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: August 2016

Production reference: 1300816

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham 

B3 2PB, UK.

ISBN 978-1-78646-363-0

www.packtpub.com

Credits

Authors

Francesco Marchioni

Luigi Fugaro

Copy Editor

Safis Editing

Reviewer

Mauro Vocale

Project Coordinator

Devanshi Joshi

Commissioning Editor

Amarabha Banerjee

Proofreader

Safis Editing

Acquisition Editor

Reshma Raman

Indexer

Rekha Nair

Content Development Editor

Samantha Gonsalves

Graphics

Jason Monteiro

Technical Editor

Jayesh Sonawane

Production Coordinator

Melwyn D'sa

About the Authors

Francesco Marchioni is a Red Hat Certified JBoss Administrator (RHCJA) and Sun Certified Enterprise Architect working at Red Hat 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 2.X release.

He has spent 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.

Over the last 10 years, he has authored many technical articles for OReilly Media and ran an IT portal focused on JBoss products (http://www.mastertheboss.com).

He has authored multiple books for Packt Publishing such as JBoss AS 5 Development  (http://www.packtpub.com/jboss-as-5-development/book), JBoss AS 5 Performance Tuning (http://www.packtpub.com/jboss-5-performance-tuning/book), JBoss AS 7 Configuration Deployment Administration (http://www.packtpub.com/jboss-as-7-configuration-deployment-administration/book), JBoss 7 Development (https://www.packtpub.com/application-development/jboss-7-development), and MongoDB Java Developers ( https://www.packtpub.com/application-development/mongodb-java-developers).

I would like to express my gratitude to the many people who helped me write this book and assisted in editing and proofreading. So, in strict alphabetical order, I'd like to thank Alessandro Arrichiello, who shared his valuable experience on the Red Hat infrastructure and gave the installation chapter a deep cut. Many thanks to the engineers at Red Hat who provided helpful insights on the new server release, in particular Josef Cacek for the awesome Kerberos stuff published on GitHub and Pedro Igor Silva for the elytron bits. A warm thanks to Luigi Fugaro, who launched the idea of writing this book together along with a nice cup of espresso and scaled this wall with me. This book would not be complete without the careful reviews of Mauro Vocale, who shared a valuable amount of his time to help us on it. And last but not least, thanks to Samantha Gonsalves, our content editor from Packt Publishing, for her patience and professionalism demonstrated in this bleeding-edge project.

Luigi Fugaro had his first encounter with computers back in the early 80s when he was still a kid. He started with a Commodore Vic-20, passing through a Sinclair, a Commodore 64, and an Atari ST 1040, where he spent days and nights giving breath mints to Otis. Then he took a big jump to a 486DX2 66MHz and started programming in Pascal and Basic.

In 1998, he started his career as a webmaster doing  HTML, JavaScript, Applets, and some graphics with Paint Shop Pro. He then switched to Delphi, Visual Basic, and finally, started working on Java projects.

While working on Java, he met a lot of people who helped him get more and more hard and soft skills. Luigi has been developing in Java, all kinds of web applications, dealing with both backend and frontend frameworks, for various system integrators.

During his years in Red Hat, Luigi met extraordinary people, both for personal and professional reasons, who believed in him and helped him in his carrier.

He is still working with Red Hat, where he can count on a wide group of highly talented people who help him daily. He would like to mention all of them, but a few of them need special recognition: Ugo, Grande Marinelli, Nonno, Mr. Bernacchi, Frank, 3A, Vocal, eljeko, Scardy, Rinaldo (don’t mind the order).

He has authored WildFly Cookbook by Packt Publishing.

A special thanks goes to the content editor, Samantha Gonsalves, who helped me a lot with her talent and patience.

A very very big THANK YOU goes to my friend and colleague, Mauro Vocale, for his precious work of reviewing and testing all the technical aspects of the book! 

About the Reviewer

Mauro Vocale was born on March 25, 1980 in Venaria Reale, Italy.

He started working on Java and Linux OS in 2001, and he is currently working with Red Hat, which gives him the opportunity to interact with some open source communities.

He is certified Oracle Master Java SE Developer and Oracle Web Component and EJB Developer for JEE 6 also over the last 10 years he worked as a Java consultant to tried to spread the open source technologies and the idea of free software.

I would like to thank my wife, Silvia, for her help and support during the challenge of my work, and my beautiful children, Alessio and Fabrizio.

www.PacktPub.com

For support files and downloads related to your book, please visit www.PacktPub.com.

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

https://www2.packtpub.com/books/subscription/packtlib

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.

Why subscribe?

Fully searchable across every book published by PacktCopy and paste, print, and bookmark contentOn demand and accessible via a web browser

Free access for Packt account holders

If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.

 

Yesterday I was a writer. Today I'm a writer. Tomorrow I'll probably still be a writer. Sigh! There's so little hope for advancement in this world.

  --Francesco Marchioni (inspired by  C.Schultz's masterpiece)
 

I’d like to dedicate this book to my Dad, who passed away this year. I’d also like to dedicate this book to my daughter Giada, the love of my life.

  --Luigi Fugaro

Preface

JBoss Application Server has been, de facto, the open source platform to provision enterprise Java applications. The commercial platform that supported the release of the application server is JBoss Enterprise Application Platform (JBoss EAP), which has just hit its 7th release.

This release contains the advanced features developed for the upstream project—now called WildFly Application Server (currently at version 10)—such as the newly designed web subsystem, Undertow, which uses the latest non-blocking I/O features of Java to provide improved scalability and performance. Undertow also supports the latest standards for web applications, such as HTTP/2, HTTP Upgrade, and WebSockets.

Another change in the application server platform is the messaging subsystem, which is now based on the unified messaging technology for Red Hat products, called Apache ActiveMQ Artemis. Active MQ Artemis enables customers to exchange messages between JBoss EAP 6 and 7, while preserving the performance, scalability, and reliability of the EAP 6's HornetQ.

JBoss EAP 7 also features several significant management updates by giving administrators the ability to see and manage the configuration of JBoss EAP servers offline, or using the new server suspend mode to gracefully shut down the servers only after completing the in-flight transactions.

The preceding list is a non-exhaustive collection of features that will be discussed throughout this book, which will guide you through the core aspects of the Enterprise server, focusing on practical use cases and describing how to solve common issues.

What this book covers

Chapter 1, Installation and Configuration, introduces you to the application server platform and provides details about the installation, available server modes, and the management instruments (Web console  and CLI).

Chapter 2, The CLI Management Tool, describes how you can configure and manage your JBoss EAP 7 platform using the CLI, using its auto completion feature, offline mode, and script files.

Chapter 3, Managing EAP in Domain Mode, goes in depth with the application server management using the domain mode, showing how to design advanced domain configurations and handle disaster and recovery scenarios.

Chapter 4, Deploying Applications, explains the different ways you can deploy your applications. Either by CLI, Web console, or filesystem, all a deployment's life cycle is managed by the platform itself and for both standalone and domain mode.

Chapter 5, Load Balancing, is about balancing requests to EAP 7 servers from a Web frontend layer.

Chapter 6, Clustering EAP 7, goes in depth to support and better configure your environment by providing a fault tolerant system with failover capabilities.

Chapter 7, Logging, provides a comprehensive description of the logging services available in the application server, teaching you how to build a scalable logging system.

Chapter 8, Configuring Database Connectivity, explains how to configure a datasource using the CLI. Adding a JDBC driver, defining a connection pool, choosing between an XA and a non-XA Datasource, and hardening the configuration is all described in depth.

Chapter 9, Configuring EAP 7 for Java EE Applications, describes how to configure the services needed for server-side applications through the application server subsystems.

Chapter 10, Messaging Administration, goes in detail about message-oriented middleware and how the JBoss EAP 7 platform can help rely on Apache Artemis as its default implementation.

Chapter 11, Securing the Application Server, discusses securing the application server infrastructure, including the applications running on top of it.

Chapter 12, New Security Features of EAP 7, is a preview of the upcoming security features available in the EAP 7.1 release and how to centralize security concerns of Web applications with the Red Hat Single Sign-On (SSO) server.

Chapter 13, Using EAP 7 with Docker, shows how to use the Docker technology to provision EAP 7 in the Enterprise.

Chapter 14, Running EAP 7 on the Cloud Using OpenShift, shows how applications leverage the new Red Hat PaaS (based on Docker and Kubernetes) to scale automatically and in any environment.

What you need for this book

To fully benefit from this book, you first need a PC, possibly running a Linux-like system, with at least 4 GB of RAM and around 10 GB of free disk space. Also, an Internet connection is a must.

From a software point of view, you will need JDK 8 and, of course, JBoss EAP 7.x. Furthermore, you should install Git and Maven.

Who this book is for

Java system administrators, developers, and application testers will benefit from this book. You are not expected to have accumulated a lot of experience on the earlier versions of the application server, though you must know the basic concepts of the Java and Linux operating system.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message.

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 at 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.

Downloading the example code

You can download the example code files for this book from https://github.com/mjbeap7 or from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

Log in or register to our website using your e-mail address and password.Hover the mouse pointer on the SUPPORT tab at the top.Click on Code Downloads & Errata.Enter the name of the book in the Search box.Select the book for which you're looking to download the code files.Choose from the drop-down menu where you purchased this book from.Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

WinRAR / 7-Zip for WindowsZipeg / iZip / UnRarX for Mac7-Zip / PeaZip for Linux

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from http://www.packtpub.com/sites/default/files/downloads/MasteringJBossEnterpriseApplicationPlatform7_ColorImages.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted 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 [email protected] 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

If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.

Chapter 1. Installation and Configuration

Red Hat JBoss Enterprise Application Platform 7.0 ( JBoss EAP 7) is a middleware platform built on open standards and compliant with the Java EE 7 specification.

It is derived from the upstream project Wildfly 10 and provides ready-to-use features such as high-availability clustering, messaging, and distributed caching.

JBoss EAP 7 is designed with a modular structure that allows on-demand services, thus greatly improving startup speed. Thanks to its web based management console and its powerful Command Line Interface (CLI), editing XML configuration files is unnecessary (and is even discouraged!). The CLI also adds the ability to script and automate management tasks. Internally, JBoss EAP includes APIs and development frameworks for quickly developing fast, secure, and scalable Java EE applications compliant with the Java EE 7 specification.

The first part of this book will let you conquer the management instruments and the EAP 7 domain configuration. When you have completed all green bars, we will concentrate on advanced topics, showing the improvements from the earlier release of the server.

As far as this chapter is concerned, we will now have a quick tour of its technology covering these topics:

What the installation options are and how to choose the one that works better for your contextHow to perform the basic administration stepsThe essentials of the server configuration

What's new in EAP 7?

If you are arriving from a JBoss EAP 6 environment you will be eager to know about the highlights of the new platform. Broadly speaking, the changes encompass both the server administration area and the Java Enterprise APIs that can help to provide applications on it. We will start by introducing the new administrative features and then we will briefly mention the API highlights.

The administrative features are described as follows:

Undertow web server: JBoss Web has for quite a long time been the face of the web application server. Although compatible with Servlet/JSP Specifications it has kept the long-term legacy with Tomcat. The new Undertow web server has been built from scratch using the best-of-breed Java IO API. Some of its core features include non-blocking NIO based APIs, a lightweight and fully embeddable architecture based on pluggable handlers, and support for WebSockets, including JSR-356 and the HTTP Upgrade mechanism. Besides this, Undertow is capable of working as a reverse proxy or load balancer for a clustered application server, opening the door to the full JBoss clustering platform.Simpler server management: Thanks to the HTTP upgrade mechanism available in Undertow, now you can reduce the number of ports in the default installation to just two:

* 8080 for applications with JNDI and EJB multiplexed

* 9990 for management, for both HTTP/JSON and native API

Support for HTTP/2: The new web server architecture supports the new version of the HTTP protocol, named HTTP/2. HTTP/2 aims to reduce latency and make efficient use of the TCP connection by means of binary framing, request/response multiplexing, header compression (HPACK) and more.New life cycle modes: It is now possible to suspend and resume the execution of the application server. This allows active sessions/requests/in-flight-txs to complete and can be used for a graceful server shutdown scenario.Enhanced server management: The administration web console has been revamped with a new graphical layout and new availabilities such as the Datasource wizard that will let you quickly create database connections with a few touches.ArtemisMQ Messaging Broker: In the new server version, the messaging broker has changed to ArtemisMQ which is directly derived from the former HornetQ. Former HornetQ clients will be supported out of the box, while offering compatibility to Apache's ActiveMQ 5.0 clients as well.ORB Switch: The new version of the application server has switched to OpenJDK ORB which provides better interoperability with other vendors compared with the earlier JacORB implementation.

The Java EE 7 API highlights are related to the the Java EE 7 (JSR 342) specification is an umbrella specification which encompasses 33 single specifications. There have been brand new technologies and improvements of existing ones.

Here is a short list of Java EE 7 drivers:

JSR-352 batch applications for the Java platform, featuring a new API for an XML-based job specification language and a runtime API.JSR-236 concurrency utilities for JavaEE, providing a simple and standard API for using multiple threads from Java Enterprise components.JSR-353 Java API for JSON Processing (JSON-P). This API can be used to parse, transform, and query JSON data.JSR-356 WebSockets support, featuring a full-duplex communication channel between the client and the server by means of simple annotations and life cycle callbacks.

Besides the new additions, some updates have been released to existing services. The most notable ones are as follows:

JSR-345, which includes EJB 3.2, plus Interceptors 1.2 and Annotations 1.2JSR-340, featuring Servlet 3.1: non-blocking I/O, HTTP upgrade, and so onJSR-342, including the JMS 2.0 API that delivers a JMSContext resource as a wrapper for JMS resourcesJSR-344 JSF 2.2: HTML 5, FaceFlows, Stateless views, Resource lib contracts

Installing EAP 7

Installing the application server can be done in several ways. For the purpose of learning we will start with the basic unzipping installation which will produce a vanilla installation ready to be used. In real-world scenarios with dozens of customized installations to be completed, you will probably want to learn some advanced installation tactics. Don't worry, we have been trained for it and you will be too in a while.

Installing from the ZIP file

The first one we will detail is also the simplest, which merely requires unzipping a file. The JBoss EAP 7 ZIP file is available from the Red Hat Customer Portal. This method of installation is platform-independent and requires the following steps:

Open a browser and log into the Customer Portal at https://access.redhat.com.Click Downloads.Select Red Hat JBoss Enterprise Application Platform in the Product list and click on it.In the next window, select the correct JBoss EAP version from the Version combobox and click Download.

JBoss EAP 7 is now downloaded to your target machine, ready for installation. Execute the following command in order to unzip the archive:

unzip jboss-eap-7.0.0.zip

Now you can test that the installation was successful by executing the standalone.sh shell script (Windows users will launch the standalone.cmd equivalent).

cd jboss-eap-7.0cd bin$ ./standalone.sh

Tip

When to use ZIP installation:

The ZIP installation can be used for developers or simple environments where it's just fine to provide a basic default installation of the server, with all the configuration and libraries in the standard folders. Therefore, it's not the best choice for large enterprise systems where you want to automate and customize installations.

Installing EAP from RPM

This method of installation is peculiar of JBoss EAP and can be a practical solution if you want to manage your application ecosystem through Red Hat Packet Manager (RPM) archives.

Installing JBoss EAP 7 via RPM requires a subscription to the official Red Hat's repositories. You can either subscribe to the current JBoss EAP channel or a minor channel that provides a specific minor release and all applicable patches. This allows you to maintain the same minor version of JBoss EAP 7, while still staying current with high severity and security patches.

Let's see in practice how the installation can be done on a RHEL 7 operating system. First of all, we have to register our brand new server to the Red Hat Network (RHN), using our credentials (username/password) for accessing to all needed subscriptions.

The command will ask for username or password, or in case we've planned to use an internal RH Satellite 6 system, we can use a preconfigured Activation Key as an option:

# subscription-manager register

After a successful registration we need to figure out to which Pool we need to attach for downloading the EAP 7 packages. We can use the subscription-manager list command followed by the less one for searching through multiple subscriptions:

# subscription-manager list --available|lessSubscription Name: Client SKUProvides: Oracle Java (for RHEL Server) - AUS Oracle Java (for RHEL Client) Red Hat Enterprise Linux 7 High Availability Red Hat Enterprise Linux High Availability Red Hat EUCJP Support (for RHEL Server) Red Hat Enterprise Linux for Power Red Hat Enterprise Linux EUS Compute Node Red Hat Enterprise Linux for Power, big endian - Red Hat OpenShift Enterprise JBoss EAP add-on Oracle Java (for RHEL Server) - Extended Update dotNET on RHEL Beta (for RHEL Server) Red Hat Enterprise Linux Load Balancer JBoss Enterprise Web Server JBoss Enterprise Application Platform - ELS . . . . . . . . . . . . . . . . . . .

As soon as we find the right subscription (you should choose something like: JBoss Enterprise Application Platform) we have to take note of the pool ID and run the following:

# subscription-manager attach --pool 844aff014485be8a85f8d058bf198144

After that we can explore the available repositories:

# subscription-manager repos --list

We won't list here all the available repositories which is quite large; however, you have to enable only EAP, RHEL7 base rpms, extras, and optional repository, and disable all the others with the following command:

# subscription-manager repos --disable="*" --enable jb-eap-7.0- for-rhel-7-server-rpms --enable rhel-7-server-rpms --enable rhel-7-server-extras-rpms --enable rhel-7-server-optional-rpms

You can verify that the process worked as expected by simply running the following:

# yum repolist

The list should look like this:

Loaded plugins: search-disabled-reposrepo id name !jb-eap-7.0-for-rhel-7-server-rpms/7Server/x86_64 (RPMs)!rhel-7-server-extras-rpms/x86_64 (RPMs)!rhel-7-server-optional-rpms/7Server/x86_64 (RPMs)!rhel-7-server-rpms/7Server/x86_64 (RPMs)repolist: 19,727

Complete the installation by executing the following:

# yum groupinstall jboss-eap7

Tip

When to use RPM installation:

The RPM installation makes things a lot easier in terms of installation because you can use all the tools that know how to deal with RPMs, and upgrading is simpler because you can use yum to do it, especially for security errata. The JBoss RPMs put things where many RHEL system administrators would expect them: config files under /etc, content and libraries under /var, and so on.

Most of the downsides come from being forced to do things the way RHN/RPMs want to do them. You cannot install multiple version of JBoss in parallel, which may not be an issue if you spin up a new VM per instance, but can be for some people. It is also difficult to install non-current versions, since you either need to manually specify the versions of several hundred packages or use satellite with a date cutoff on a custom cloned channel to hide any packages from newer releases.

Installing from the JAR installer

The JBoss EAP 7 installer archive is also available from the Red Hat Customer Portal (https://access.redhat.com). The .jar archive can be used to run either the graphical or text-based installers.

In order to complete the JAR installation, follow these steps:

Open a terminal and navigate to the directory containing the downloaded installation program JAR.Type the following command:java -jar jboss-eap-7.0.0-installer.jar As an alternative, if you have just a terminal available, use the text only mode by launching the following command:
java -jar jboss-eap-7.0.0-installer.jar -console

We will not detail the single steps of the installation which are quite intuitive and covered by the EAP installation guide. Rather we would like to stress that the installer produces an XML script; you can reuse it for multiple installations, as you can see from the following picture:

If you open the generated XML file, then you can pinpoint some custom elements in the installation:

<?xml version="1.0" encoding="UTF-8" standalone="no"?> <AutomatedInstallation langpack="eng"> <productName>EAP</productName> <productVersion>7.0.0</productVersion> <com.izforge.izpack.panels.HTMLLicencePanel id="HTMLLicencePanel"/> <com.izforge.izpack.panels.TargetPanel id="DirectoryPanel"> <installpath>/home/francesco/EAP-7.0.0</installpath> . . . . . </AutomatedInstallation>

Then you can repeat the installation with the following command:

java -jar jboss-eap-7.0.0-installer.jar -xml yourxml

Tip

When to use the JAR installer:

We would recommend using the JAR installer for medium to large sized environments where you have some common defaults for networks, database connectivity, or security settings. Another advantage of this approach is that it can be used for any operating system as it's completely Java based.

Installing from the source

Downloading the source code can be used if you need low-level details about the single modules of the application server. Once you have downloaded the jboss-eap-7.0.0-src.zip file, unzip it to your disk at first. Next you can build the server in two ways:

Executing the batch script (build.sh or build.bat for Windows)If you have Maven 3.2.5 (or newer) installed you can use it directly as follows:
$ mvn install

Change to the bin directory after a successful build:

$ cd build/target/jboss-eap/bin

Verify that the application server boots successfully:

$ ./standalone.sh

Other installation options

The amount of installation options for EAP could well deserve one or more chapters; however, that would take us away from the scope of this book. We will just mention Ansible, which is an excellent configuration management and provisioning tool that uses SSH to perform administrative tasks on your machines. This has the evident advantage that nothing needs to be installed on the machines you are targeting as Ansible only runs on your main control machine, which could even be your laptop!

The steps used by Ansible to provision and configure machines are described in a kind of template called Playbooks, which are Ansible's configuration, deployment, and orchestration language.

You can find a large list of example Playbooks in the Ansible documentation, available at http://docs.ansible.com/ansible . Besides this, for testing purposes we have provided a sample EAP 7 playbook which is attached to the sources of this book. (Read the instructions contained in the README.txt file packaged in ansible.zip.)

Besides this, if you want a user interface for your provisioning activities, Ansible Tower is a web-based solution that makes Ansible even more easy to use for IT teams of all kinds. It's designed to be the hub for all of your automation tasks.

Starting the application server

The scripts for starting the server are contained in the JBOSS_HOME/bin folder:

standalone.sh starts the server in standalone modedomain.sh starts the server in domain mode

An equivalent BAT file is also included for Windows users.

In order to check that your installation was successful, execute one of the startup scripts:

$ ./standalone.sh

Next surf to localhost:8080 and check the welcome page of the application server:

Stopping the application server

Stopping the application server can be done in several ways. Sending an interrupt signal (Ctrl + C) will interrupt the server abruptly, so it's not a recommended option.

So it is sending a kill -9 signal from the terminal against the application server process which is an extreme option to be used when the application server is not responsive through management channels.

The recommended approach is to connect through the Command Line Interface and execute the shutdown command:

Execute jboss-cli.sh from JBOSS_HOME/bin.Once in the command line prompt, execute the connect command:[disconnected /] connect 127.0.0.1:9990Connected to 127.0.0.1:9990 Now issue the shutdown command that will stop the application server:[127.0.0.1:9990 /] shutdownThe shutdown command can be also executed with the ­­restart=true parameter which will cause the application server to restart: [127.0.0.1@localhost:9990 /] shutdown --restart=true

Tip

Two things to know!

The first one is that if you don't provide any parameter to the connect command, it will use the defaults contained in the jboss-cli.xml that will attempt to connect to localhost on port 9990.

Next, if you are connecting to a remote host controller, a username/password challenge will be prompted. See the next section (Basic server administration) to learn how to create a management user.

Basic server administration

Once the installation has been completed, it's about time to complete some basic administration tasks. The most obvious one involves creating one or more users for managing your platform. Out of the box, a script called add-user.sh is provided along with your installation. The purpose of this script is to manage two different types of user:

Management users: users in charge of administrating your application serverApplication users: users in charge of accessing your applications

Note

Important notice!

The add-user script uses a very simple file-based mechanism to store the users' information. This can be acceptable for basic security requirements. Real-world scenarios, however, would need to use more appropriate security polices as detailed in Chapter 11, Securing the Application Server, of this book.

You can execute the add-user script both in an interactive way and in an automatic way.

In order to execute the add-user script in an interactive way, just execute it as follows and provide the requested information:

$ ./add.user.shWhat type of user do you wish to add? a) Management User (mgmt-users.properties) b) Application User (application-users.properties)(a): aEnter the details of the new user to add.Using realm 'ManagementRealm' as discovered from the existing property files.Username : administrator1. . . . .Password : Re-enter Password : What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[ ]: About to add user 'administrator1' for realm 'ManagementRealm'Is this correct yes/no? yesTo represent the user add the following to the server- identities definition <secret value="UGFzc3dvcmQxIQ==" />

We have removed some negligible information from the output so that you can focus on the required arguments of the script. The previous information can be filled in also in a non- interactive way by providing the username with the -u parameter, the password with the -p, and the group (if needed) with -g. You can discriminate between management users and application users with the -m and -a parameters.

Here is how to create a management user:

$ ./add-user.sh -m -u administrator1 -p Securepassword1!

Note

Once you have created the management user, you can verify that the login correctly lets you through the management console, which is available at http://localhost:9990.

On the other hand, here is the shell script to create an application user belonging to the guest group:

$ ./add-user.sh -a -u demouser -p Securepassword1! -g guest

Note

Beware that creating users in a non-interactive way exposes your user/password information across the shell history system process table if you are a Linux user.

Once you have created your users the following files (contained in the configuration folder of your server base directory) will be updated:

-rw-rw-r--. 1 francesco francesco 711 Oct 26 06:13 application-roles.properties-rw-------. 1 francesco francesco 935 Oct 26 06:13 application-users.properties-rw-rw-r--. 1 francesco francesco 646 Nov 24 16:11 mgmt- groups.properties-rw-------. 1 francesco francesco 1111 Nov 24 16:11 mgmt- users.properties

The application-roles.properties holds the list of roles granted to application users. The file application-users.properties contains the list of application users and their hashed passwords. Conversely, mgmt-groups.properties contains the list of roles granted to management users and  mgmt-users.properties holds the management users and their hash passwords. As a final note, the password contained in *-users.properties files is in hash using this format:

username=HEX( MD5( username ':' realm ':' password))

Note

How to recover the password

Being an MD5 based hash means that the password is not reversible. On the other hand, consider that most hashes are also non-unique; rather, they're unique enough, so a collision is highly improbable, but still possible.

EAP 7 basic configuration

JBoss EAP provides two operating modes for the servers: the standalone mode and the domain mode. A standalone server is a Java process which is governed by a single management point using a configuration file. A domain server, on the other hand, is a group of Java processes which are managed through a single point called the Domain Controller and its configuration file.