Anda di halaman 1dari 32

Table of Contents

1. WildFly Administration Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  1


1.1. Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  1
1.2. Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  1
1.3. The Author of the Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  2
1.4. The reviewers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  3
1.5. What this book covers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  3
1.5.1. Who this book is for . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  4
1.5.2. How to Contact Us . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  4
1.5.3. Piracy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  4
1.5.4. Book Version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  5
1.5.5. Conventions used in this book. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  5
2. Getting started with WildFly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  7
2.1. What is new in WildFly ? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  7
2.1.1. Changes happened since WildFly 8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  7
2.1.2. Changes happened since WildFly 9 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  8
2.1.3. Changes happened since WildFly 10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  9
2.1.4. Changes happened since WildFly 11 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  10
2.1.5. Changes happened since WildFly 12 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  10
2.1.6. Changes happened since WildFly 13 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  11
2.1.7. Changes happened since WildFly 14 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  11
2.2. Installing WildFly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  11
2.3. An in-depth look into the application server file system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  12
2.4. Starting WildFly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  14
2.4.1. Setting the JBOSS_HOME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  15
2.5. Your first task: Create an Administrator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  16
2.5.1. Creating an user in non-interactive mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  17
2.6. Stopping WildFly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  17
2.6.1. Stopping WildFly running on a remote host . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  18
2.7. Handling start-up issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  18
2.8. Installing WildFly as Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  20
2.8.1. Linux users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  20
2.8.1.1. Installing WildFly as a Service using init.d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  20
2.8.1.2. Installing WildFly as a Service using systemd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  22
2.8.2. Windows users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  22
3. Core Server configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  24
3.1. The two available server modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  24
3.2. Understanding the server configuration file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  25
3.2.1. Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  25
3.2.2. Paths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  26
3.2.3. Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  27
3.2.4. Socket binding groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  27
3.2.5. System-Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  28
3.2.6. Profile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  29
3.3. Configuring WildFly in Standalone mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  29
3.3.1. Configuring JVM settings in Standalone Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  30
3.3.2. Configuring Network Interfaces in Standalone Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  30
3.3.3. Configuring Socket Bindings in Standalone Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  31
3.3.4. Configure Path references in Standalone Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  31
3.3.5. Configuring System Properties in Standalone Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  32
3.4. Configuring WildFly in Domain mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  32
3.4.1. Configuring the Domain Controller – Part 1: domain.xml . . . . . . . . . . . . . . . . . . . . . . . . . . . .  34
3.4.2. Configuring the Domain Controller – Part 2: host.xml . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  35
3.4.3. Configuring the Host Controllers (host.xml) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  35
3.4.4. Domain breakdown . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  38
3.5. Managing the WildFly Domain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  39
3.5.1. Mananaging the Domain Profiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  40
3.5.2. Mananaging the Domain Hosts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  40
3.5.2.1. Managing the Host controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  42
3.5.3. Managing the Server Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  43
3.6. Domain Controller Failover . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  43
3.6.1. Using Multiple Protocols to reconnect to the Domain Controller . . . . . . . . . . . . . . . . . . . . . .  45
3.6.2. Using Multiple Hosts in the Discovery Opions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  46
3.7. Standalone mode vs Domain mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  46
4. Server Management with Web console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  47
4.1. Connecting to the Web console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  47
4.2. Varying the Server Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  48
4.3. Gathering Runtime statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  49
4.4. Managing the Domain with the Console. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  51
4.4.1. Varying your Domain setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  52
4.4.2. Configuring Domain JVM Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  54
4.4.2.1. Configuring Host JVM Settings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  54
4.4.2.2. Configuring Server Groups JVM Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  55
4.4.2.3. Configuring Server JVM Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  56
4.5. Using the Web console’s Management Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  57
4.6. Admin Console or not ?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  58
5. Server Management with the CLI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  60
5.1. Starting the Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  60
5.1.1. Recovering your server configuration using the CLI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  61
5.2. Using the CLI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  61
5.3. Build up the CLI commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  63
5.3.1. Determine the resource address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  63
5.3.2. Reading attributes of resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  63
5.3.3. Writing attributes of resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  64
5.3.4. Adding new resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  64
5.3.5. Reading children resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  65
5.3.6. Extra operations available on resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  66
5.4. Tracing CLI commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  66
5.4.1. In-memory configuration changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  67
5.5. Running the CLI in graphical mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  67
5.5.1. Adding resources in graphical mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  69
6. Advanced CLI features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  70
6.1. Using CLI batch mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  70
6.1.1. More about batch commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  71
6.2. Using batch deployments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  72
6.3. Applying patches to your configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  73
6.4. Taking snapshots of your configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  75
6.5. Running the CLI in offline mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  77
6.6. Suspending and resuming the Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  78
6.7. Graceful shutdown of the Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  80
6.8. Conditional execution with the CLI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  80
6.9. Migration of legacy systems with the CLI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  81
7. Deploying applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  83
7.1. File system deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  83
7.1.1. Mode 1: Auto-deploy mode: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  83
7.1.2. Mode 2: Manual deploy mode: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  83
7.1.3. Configuring the Deployment scanner attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  84
7.2. Deploying using the Web interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  85
7.2.1. Standalone Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  85
7.2.2. Domain Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  87
7.2.2.1. Managing your application status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  90
7.3. Deploying the application using the CLI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  91
7.3.1. Manipulating exploded deployments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  92
7.3.2. CLI Domain deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  92
7.4. Deploying applications using Maven . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  93
7.4.1. Domain Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  94
8. Configuring Database connectivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  95
8.1. Creating a Datasource using the CLI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  95
8.1.1. Creating a Datasource in Domain mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  97
8.1.2. Creating an XA Datasource . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  97
8.1.2.1. Enabling XA transactions on the DB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  98
8.2. Configuring a Datasource using the Admin Console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  98
8.3. Deploying a Datasource as a resource . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  102
8.3.1. Packaging Datasources in your applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  103
8.4. Configuring Datasources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  104
8.4.1. Configuring the Datasource pool attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  104
8.4.2. Configuring flush strategies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  105
8.4.3. Protecting a Datasource credentials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  106
8.4.3.1. Step 1: Generate the encrypted password . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  107
8.4.3.2. Step 2: Create the Security Domain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  107
8.4.3.3. Step 3: Let your datasource use the Security Domain: . . . . . . . . . . . . . . . . . . . . . . . . . .  108
8.4.4. Masking your Datasource credentials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  109
8.4.5. Using System Properties in your deployable data sources . . . . . . . . . . . . . . . . . . . . . . . . . .  109
8.4.6. Configuring Multi Datasources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  110
8.5. Policies for creating/destroying connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  110
8.5.1. Configuring the incrementer capacity policy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  110
8.5.2. Configuring the decrementer capacity policy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  112
8.6. Gathering runtime statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  113
8.6.1. Detecting leaked connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  115
8.7. Configuring Agroal Datasource . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  116
8.7.1. Creating an Agroal XA Datasource . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  117
9. Configuring Undertow Webserver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  119
9.1. Entering Undertow Web server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  119
9.2. Configuring Undertow Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  120
9.2.1. Adding a connection limit filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  121
9.2.2. Adding a gzip filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  121
9.2.3. Adding an error filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  121
9.2.4. Adding a custom filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  122
9.3. Configuring Undertow Handlers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  122
9.3.1. Configuring a File based Handler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  123
9.3.2. Creating a Reverse Proxy Handler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  124
9.4. Configuring Undertow Listeners . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  125
9.4.1. Configuring the Web server Pool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  126
9.4.2. Configuring a custom Worker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  127
9.4.3. Other listeners attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  128
9.5. Configuring Undertow Buffer Pool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  129
9.6. Configuring the Servlet Container and JSP Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  130
9.7. Gathering statistics about Web applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  134
9.8. Configuring HTTP/2 Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  135
9.9. Configuring EJB calls over Undertow’s HTTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  135
10. Configuring the EJB Container . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  136
10.1. Configuring the EJB Pools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  136
10.2. Configuring the MDB delivery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  138
10.2.1. Configuring MDB Group delivery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  139
10.3. Configuring the Stateful Session Bean cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  139
10.3.1. Enabling Passivation for Stateful Session Beans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  141
10.3.2. Disabling Passivation for a single deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  141
10.3.3. Setting the Access timeout for SFSBs and Singleton beans . . . . . . . . . . . . . . . . . . . . . . . . .  142
10.4. EJB3 Thread pool configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  143
10.4.1. Configuring the EJB thread pool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  144
10.4.2. Gathering runtime statistics of the thread pool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  145
10.4.3. Configuring Remote EJB Transport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  146
10.4.4. Enabling statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  146
10.4.5. Configuring a different Resource Adapter for your MDBs . . . . . . . . . . . . . . . . . . . . . . . . .  147
11. Configure Logging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  151
11.1. WildFly default logging configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  151
11.2. Configuring Log Handlers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  152
11.2.1. Configuring the Periodic Rotating Handler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  152
11.2.1.1. Changing the path where the log is written . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  153
11.2.1.2. Formatting the log output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  154
11.2.1.3. Filtering the logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  154
11.2.2. Adding a new Handler: the Size Rotating Handler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  155
11.2.2.1. Adding the handler from the Web console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  155
11.2.2.2. Adding the handler from the CLI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  156
11.2.3. Creating a Custom Handler that writes logs to the Database . . . . . . . . . . . . . . . . . . . . . . .  156
11.2.4. Creating a Custom Handler that writes logs via Socket . . . . . . . . . . . . . . . . . . . . . . . . . . . .  157
11.2.5. Configuring Handlers to be asynchronous . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  158
11.3. Configuring the Root Logger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  158
11.4. Configuring Logging Categories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  159
11.5. Other Logging configuration files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  161
11.5.1. Using Log4j to trace your application logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  161
11.5.2. Disabling the core logging API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  162
11.6. Other ways to read the log files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  162
11.6.1. Reading Logs with the Command Line Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  162
11.6.2. Reading logs using the HTTP channel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  163
12. Configuring JMS Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  164
12.1. ActiveMQ Artemis overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  164
12.1.1. Artemis ActiveMQ architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  164
12.1.2. Socket Management in ActiveMQ Artemis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  165
12.1.3. Starting WildFly with JMS Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  166
12.2. Configuring JMS Connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  167
12.2.1. Additional properties you can set on Connectors and Acceptors . . . . . . . . . . . . . . . . . . .  168
12.2.2. Switching to Netty sockets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  169
12.3. Creating JMS Destinations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  170
12.3.1. Built-in Queues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  173
12.3.2. Creating Queues and Topics using the Command Line Interface . . . . . . . . . . . . . . . . . . .  173
12.3.2.1. Creating deployable JMS destinations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  173
12.3.3. Customizing JMS destinations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  174
12.4. Configuring Message Persistence. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  176
12.4.1. Configuring File system journal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  176
12.4.1.1. Changing the location where the Journal is persisted. . . . . . . . . . . . . . . . . . . . . . . . . .  177
12.4.1.2. Configuring Message Paging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  178
12.4.1.3. Configuring the paging folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  178
12.4.2. Configuring JDBC Storage for messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  179
12.4.2.1. Varying the default Journal Table Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  180
12.5. Routing Messages to other destinations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  180
12.5.1. Diverting messages to other destinations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  180
12.5.2. Creating a Bridge between two ActiveMQ Artemis servers . . . . . . . . . . . . . . . . . . . . . . . . .  182
12.5.2.1. ActiveMQ Artemis target configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  182
12.5.2.2. ActiveMQ Artemis source configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  182
12.5.2.3. Bridging messages to another JMS Broker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  185
12.6. JMS Clustering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  185
12.6.1. HA with Shared Store . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  186
12.6.2. HA with data replication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  186
12.6.3. Cluster core configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  187
12.6.4. Server Discovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  189
12.6.4.1. Broadcast Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  189
12.6.4.2. Discovery Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  190
12.6.5. Starting your cluster of Artemis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  191
12.6.6. Configuring a static discovery of cluster nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  191
13. Classloading and modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  193
13.1. What are modules ? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  193
13.2. Configuring static modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  194
13.2.1. How to install a new module. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  194
13.2.1.1. Example: How to install Jython library as a module . . . . . . . . . . . . . . . . . . . . . . . . . . .  195
13.2.1.2. How to use an installed module in your application . . . . . . . . . . . . . . . . . . . . . . . . . . .  196
13.2.1.3. How to turn your modules in a global module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  196
13.2.1.4. How to deploy extension-type dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  197
13.3. Configuring dynamic modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  197
13.3.1. How to use dynamic modules in your applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  197
13.4. Configuring module Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  198
13.4.1. Implicit dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  198
13.4.2. Explicit dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  199
13.5. Advanced Classloading policies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  200
13.5.1. How to prevent your modules from being loaded . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  201
13.5.2. How to prevent a subsystem from being loaded . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  202
13.5.3. Configuring classloading isolation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  203
13.5.4. Sticking to Java EE compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  204
13.6. Creating Custom servers using Feature Packs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  204
13.6.1. Provisioning a Feature Pack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  205
13.6.2. Merging feature packs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  208
14. Clustering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  210
14.1. WildFly clustering building blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  210
14.2. Clustering standalone nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  211
14.2.1. Clustering standalone servers on different machines . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  211
14.2.2. Clustering standalone servers on the same machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  211
14.3. Configuring a cluster of domain nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  212
14.3.1. Enabling clustering services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  213
14.4. Configuring the Cluster transport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  214
14.4.1. Changing the Protocol Stack used by JGroups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  215
14.4.2. Configuring a full TCP stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  216
14.4.3. Other JGroups stacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  217
14.4.4. Configuring the Transport Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  219
14.4.5. Configuring the Protocol Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  220
14.5. Configuring Clustering Caches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  221
14.5.1. Configuring the Cache Container top level attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  222
14.5.2. Configuring the Cache Container Transport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  224
14.6. Configuring ejb and web Cache containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  225
14.6.1. Configuring a Replicated cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  225
14.6.1.1. Creating a replicated cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  226
14.6.2. Configuring a Distributed cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  226
14.6.2.1. Providing hints to the Distributed cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  227
14.6.2.2. Adding L1 cache to a distributed cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  227
14.6.3. Configuring ejb and web Cache containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  228
14.6.3.1. Configuring cache eviction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  228
14.6.3.2. Configuring cache expiration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  229
14.6.3.3. Configuring locking for entries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  229
14.6.3.4. Configuring EJB and Web application cache Storage . . . . . . . . . . . . . . . . . . . . . . . . . .  231
14.6.3.5. Using a JDBC Cache store . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  232
14.6.3.6. Example: Defining a JDBC Cache Store . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  232
14.6.4. Controlling Passivation of HTTP Sessions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  233
14.7. Configuring hibernate Cache Container . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  233
14.7.1. Configuring Hibernate cache for Entities and Collections . . . . . . . . . . . . . . . . . . . . . . . . . .  234
14.7.1.1. Configuring eviction for hibernate cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  235
14.7.1.2. Configuring expiration for hibernate cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  235
14.7.1.3. Configuring locking for hibernate cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  236
14.7.1.4. Configuring Hibernate cache for queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  237
14.7.1.5. Configuring the Timestamp cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  237
15. Load balancing applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  239
15.1. Configuring Apache mod_jk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  239
15.1.1. Configuring Apache Web server side . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  239
15.1.2. Configuring WildFly to receive AJP requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  241
15.2. Configuring mod_cluster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  242
15.2.1. Installing mod_cluster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  242
15.2.2. Configuring WildFly for mod_cluster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  243
15.2.3. Testing your configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  244
15.2.4. A deep look into mod_cluster configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  245
15.2.5. Troubleshooting mod_cluster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  247
15.2.5.1. Check multicast communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  248
15.2.5.2. Switch additional display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  249
15.3. Advanced mod_cluster configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  249
15.3.1. Using a static list of http proxies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  250
15.3.2. How to configure mod_cluster to exclude one Web context . . . . . . . . . . . . . . . . . . . . . . . .  250
15.3.3. Configuring Sticky Sessions with mod_cluster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  250
15.3.4. Configuring Metrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  251
15.4. Configuring HA for remote EJB clients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  253
15.5. Undertow as mod_cluster Front end. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  254
15.5.1. Configuring the Back end . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  255
15.5.2. Configuring the Front end . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  255
15.5.2.1. Manually configuring the Undertow filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  256
15.5.2.2. Testing Undertow’s mod_cluster load balancer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  257
15.6. Mod-Cluster Multiplicity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  258
16. Securing WildFly with Elytron . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  261
16.1. Elytron building blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  261
16.1.1. Default Security Domain and Security Realms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  262
16.2. How to enable Elytron for Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  263
16.3. Elytron Realms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  264
16.3.1. Configuring a File System Security Realm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  265
16.3.1.1. Testing Elytron Security Realm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  266
16.3.1.2. Using other options for storing the password . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  267
16.3.1.3. Using Elytron in parallel with the Legacy security subsystem . . . . . . . . . . . . . . . . . .  268
16.3.2. Configuring a JDBC Realm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  268
16.3.3. Configuring an LDAP Realm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  270
16.3.4. Configuring a SASL Based Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  272
16.3.4.1. Configuring the EJB Server side . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  274
16.3.4.2. Configuring the EJB Client side . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  274
16.4. Securing Management interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  275
16.5. Configuring SSL/TSL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  275
16.5.1. Creating your own certificates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  276
16.5.2. Configuring One-Way SSL / HTTPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  278
16.5.3. Configuring Mutual SSL Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  280
16.5.4. Importing Client certificates on your browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  281
16.5.5. Configuring OpenSSL as SSL provider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  282
16.6. Using Credential Stores to store sensitive data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  283
16.6.1. Example: securing your Datasource password . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  283
16.6.2. Configuring the Credential Store Offline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  284
17. WildFly’s legacy security model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  285
17.1. Security building blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  285
17.1.1. Configuring Security Realms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  285
17.1.1.1. The Management Realm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  286
17.1.1.2. The Application Realm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  286
17.2. WildFly Security Domains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  287
17.2.1. Security under the hood . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  288
17.2.2. Using the RealmDirect login module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  289
17.2.2.1. Adding new Application users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  290
17.2.2.2. Defining the roles into your applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  291
17.2.3. Database Login module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  293
17.2.3.1. Using encrypted database passwords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  294
17.2.4. LDAP Login module configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  295
17.2.5. Login not working? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  296
17.2.6. Auditing Security Domains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  297
17.3. Management Security with Login Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  298
17.4. Management Security with LDAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  298
17.5. Introducing Java EE 8 API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  299
17.5.1. Secure web authentication with Java EE 8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  299
17.5.2. Managing Identity Stores with Java EE 8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  302
17.6. Enabling the Secure Socket Layer on WildFly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  303
17.6.1. Securing Web applications with SSL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  304
17.6.1.1. How to secure the application server with a CA signed certificate . . . . . . . . . . . . . .  306
17.7. Encrypting the Management Interfaces channel. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  307
17.8. WildFly support for HTTP/2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  307
17.8.1. Setting up HTTP/2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  308
18. RBAC and other Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  310
18.1. Configuring Role Based Access Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  310
18.1.1. Enabling RBAC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  311
18.1.2. Using groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  315
18.1.3. Defining Scoped Roles for Domain mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  317
18.1.3.1. Server Group-scoped roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  318
18.1.3.2. Host-scoped roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  319
18.1.4. Configuring Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  320
18.1.4.1. Configuring Sensitivity Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  320
18.1.4.2. Configuring Application Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  322
18.2. Configuring Security Manager on WildFly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  324
18.2.1. Running WildFly with a Security Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  324
18.2.2. Coding Permissions in the configuration file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  325
18.2.3. Restricting permissions at module level . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  326
19. Using WildFly with Docker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  328
19.1. First steps with Docker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  328
19.1.1. Main components of Docker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  328
19.1.2. Installing Docker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  329
19.1.2.1. OlderLinux distributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  330
19.2. Running your first Docker image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  330
19.3. Running WildFly images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  332
19.4. Extending the WildFly image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  333
19.4.1. Deploying applications on Docker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  335
19.5. Handling multiple Docker Containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  336
19.5.1. Creating Docker Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  336
19.5.2. Using Docker compose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  338
20. Configuring MicroProfile capabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  341
20.1. Configuring the MicroProfile Config . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  341
20.1.1. ConfigSources in microprofile-config-smallrye subsystem . . . . . . . . . . . . . . . . . . . . . . . . .  342
20.1.2. ConfigSource from Class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  344
20.1.3. ConfigSources in microprofile-config.properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  346
20.2. Configuring Microprofile health . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  347
20.2.1. Management Health check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  347
20.2.2. HTTP Endpoint Health check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  347
20.2.3. Beans Health Check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  348
20.3. Configuring MicroProfile OpenTracing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  348
21. Appendix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  352
21.1. The naming subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  352
21.1.1. Naming Alias . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  352
21.2. The batch-jberet subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  353
21.3. The mail subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  354
1. WildFly Administration Guide
Author : Francesco Marchioni

© ItBuzzPress 2018

1.1. Foreword
WildFly is the latest version of the popular open source JBoss application server. It is exceptionally
lightweight, featuring unparalleled speed and supporting the latest standards, including Java EE 7.
I’m Brian Stansberry, the technical lead for WildFly’s Operations, Administration and Management
(OA&M) functionality, a role I’ve been in since the start of the JBoss AS 7 project. So as you can
imagine this book’s topic is near and dear to my heart. One of the biggest priorities of AS 7, WildFly
and JBoss Enterprise Application Platform 6 has been to improve the application server’s
manageability, and after a lot of dedication, sleepless nights and coffee I feel we’ve come a long
way. I hope after reading this book you’ll agree. The biggest improvement in WildFly 8 over AS 7
besides the new Java EE 7 API compatibility is in the OA&M area with the addition of fine-grained
role based administrative access control, a feature that is a focus of the Security chapter of this
book.

I first heard about the author when he authored "JBoss AS 5 Development" in 2010 and was a JBoss
Community Recognition Award Winner for his application server documentation. For many years
now he has been an active and important part of the JBoss Application Server and WildFly
community, consistently producing high quality documentation covering the application server and
middleware in general.

I was very pleased to hear that Francesco was planning to write a book on WildFly 8. High quality
books like this one are critical to the success of open source software, and Francesco has the
expertise to cover the topic well and a great reputation for doing an excellent job.

I hope you’ll find this WildFly Administration Guide as thorough and well written as I did. WildFly’s
web console and its command line interface (CLI) administration tool are well covered, as are all of
the key areas of application server administration. This book definitely belongs on the bookshelf of
anyone administering WildFly or developing application for it.

Brian Stansberry

1.2. Preface
WildFly is the continuation of the release cycle of the application server community edition, which
was previously known as JBoss AS 7. The last official release of JBoss AS 7 was the 7.1.1.Final,
although a more recent 7.2 version is available as source to be built on Github
(https://github.com/jbossas/jboss-as/archive/7.2.0.Final.tar.gz) source code repository

You might wonder why the application server changed its popular name. Actually, there’s more
than one reason for this change, the first one being to avoid confusion between the commonly
referred community version (JBoss AS) and the Enterprise version supported by Redhat. Besides
this, in the last years lots of new projects grew up in the JBoss.org site which included the "JBoss"

1
brand in it (e.g. JBoss ESB). For this reason, the term “JBoss” was often misused sometimes to mean
the application server sometimes else to mean a brand of products.

The rename applies, however, only for the JBoss Application Server community edition. The
licensed version is still named JBoss Enterprise Application Platform (JBoss EAP). So from now on,
when someone refers to WildFly, we clearly know they are talking about the Community project
and specifically the application server project.

Besides the new brand name, the WildFly application server follows the same path traced by JBoss
AS 7: this means a truly modular and lightweight kernel with advanced management capabilities.
In addition to this, the new application version supports the latest changes in terms of Java EE
technology, offering richer management capabilities, a more advanced security control and some
important updates as well in the Web server tier.

Red Hat, Red Hat Enterprise Linux, JBoss, are trademarks of Red Hat, Inc., registered in the
United States and other countries.

Linux ® is the registered trademark of Linus Torvalds in the United States and other
countries.

Java ® is a registered trademark of Oracle and/or its affiliates.

1.3. The Author of the Book


Francesco Marchioni is a Quality Engineer working at Red Hat since 2014. He has joined the JBoss
community in early 2000 when the application server was a mere EJB container, running release
2.x.

In 2008 he started an IT portal focused on JBoss products

(http://www.mastertheboss.com) which is pleased to serve an average of 8000 daily visits.

He has authored the following titles:

JBossAS 5 Development, Packt Publishing (December 2009)

JBoss
AS 5 Performance Tuning, Packt Publishing (December
2010)

JBoss
AS 7 Configuration, Deployment, and Administration, Packt Publishing (December 2011)

Infinispan
Data Grid Platform, Packt Publishing (June 2012)
co-authored with Manik Surtani
(Infinispan Project lead)

JBoss
AS 7 Development, Packt Publishing (June 2013)

Enterprise
Application Server CookBook, ItBuzzPress (September
2013)

WildFly Administration Guide (June 2014 – Updated on


March 2018 )

Practical
Java EE Development on WildFly (June 2014 – Updated on
April 2018 )

2
In March 2018 Francesco published his first sci-fi novel named Chronicles from a Simulated World
which covers in an earthy and rational style the discussion about the Simulation Hypothesis.

1.4. The reviewers


Jaikiran Pai works at Red Hat and is part of the JBoss AS and EJB3 development team. In his role as
a software developer, Jaikiran has been mainly involved in Java language and Java EE technologies.
Since 2004 he started working in a software company in Pune, India where he developed an
interest in JBoss Application Server and has been active in the JBoss community ever since.
Subsequently, he joined Red Hat to be part of the JBoss EJB3 team. Jaikiran is one of the co-authors
of JBoss AS Getting Started DZone RefCard http://refcardz.dzone.com/refcardz/getting-started-jboss.

1.5. What this book covers


Chapter 1, Installing WildFly covers the installation of the server platform and introduces the
reader to the most significant changes brought through the releases 8, 9 and 10 of the application
server

Chapter 2, Basic server configuration discusses the core configuration of the application server
both in standalone mode and in domain mode, including detailed steps to setup a suggested domain
configuration topology.

Chapter 3, Server Management with the Web console covers the Web based administration
interface that can be used to manage the application server.

Chapter 4, Server Management with the CLI introduces the reader to the Command Line
Interface which is the recommended management tool.

Chapter 5, Advanced CLI features covers some advanced tasks that can be pursued with the CLI
such as batch scripts, suspending server execution, executing commands in offline mode and more.

Chapter 6, Deploying applications encompasses in detail all available options to deploy Java
Enterprise applications on the application server.

Chapter 7, Database connectivity, is about configuring connections to relational databases by


installing JDBC Drivers and Datasources.

Chapter 8, Configuring Undertow discusses about the new fast and furious Web server
implementation named Undertow

Chapter 9, Configuring EJB Container covers the nuts and bolds of the EJB Container
configuration

Chapter 10, Configuring Logging covers the configuration of log subsystem, including all available
log handlers, and best practices to log to your own requirements

Chapter 11, JMS Configuration is about the nuts and bolts of WildFly’s JMS provider which is now
ActiveMQ Artemis messaging system.

Chapter 12, Application Server classloading is a deep dive into the application server’s modular

3
kernel and how to configure it to load libraries needed by your applications.

Chapter 13, Clustering covers the application server clustering capabilities that serve as an
essential component to provide scalability and high availability to your applications.

Chapter 14, Load Balancing Web Applications discusses the other key concern of clustering, that
is the ability to make several servers participate in the same service and do the same work.

Chapter 15, Securing WildFly with Elytron covers the new Elytron Security subsystem

Chapter 16, Legacy Security covers the foundation of the application server Security framework
using the Legacy Security Framework

Chapter 17, RBAC and other Constraints covers aspects of the application server security, such as
Role Based Access Control which are not specific to the security framework adopted
(Elytron/legacy)

Chapter 18, Using WildFly with Docker features the application server seen from the Docker
perspective, including some basic container tasks and advanced tactics.

Chapter 19, Configuring MicroProfile capabilities introduces the new MicroProfile extensions,
which is an essential feature if you are developing portable services to be executed in container
environments.

1.5.1. Who this book is for

This book is especially suited for Java system administrators that are going to manage the new
release of the application server. Developers, and application testers will be as well more
productive after learning this book. Prior knowledge of the earlier version of the application server
is not required, although that could make easier to understand some core concepts contained in
this book.

1.5.2. How to Contact Us

Please address comments and questions concerning this book to the publisher:
info@itbuzzpress.com. We have created a web page for this book, where we list errata, examples,
and any other information. You can access this page at:
http://www.itbuzzpress.com/news/wildflyadmin-errata.html

For more information about our books, and future projects see our website at:
http://www.itbuzzpress.com

1.5.3. Piracy

The uploading/downloading of copyrighted material without the express written consent of the
content copyright holder is strictly forbidden. Piracy is an illegal act that you may aspire to
reconsider. Besides this, piracy is not a victimless crime! It is financially damaging and personally
hurtful to company employees and their families. Legitimate users suffer as well. We appreciate
your help in protecting the valuable content of this book.

4
1.5.4. Book Version

This is the version 1.5 of the book – Updated 19 September 2018

1.5.5. Conventions used in this book

This book contains lots of script files and commands to be executed on your machine. Much effort
has been put to make the code as much as readable as possible.

The following script snippet (in a blizzard blue) identifies a command to be executed on your
operating system’s shell:

$ ./jboss-cli.sh

As you can see from the prompt, we have assumed that you are executing on a Linux/Unix
machine. At the beginning of the book, we have also provided the equivalent Windows syntax of
some core commands:

C:\Users\jboss\wildfly-14.0.0.Final\bin jboss-cli.bat

To avoid being repetitive, we have however used the Linux shell syntax for the rest of the book.

Within the book, you will find also some gray-filled block of code like the following one:

[disconnected /] patch apply /tmp/wildfly-9.0.1.Final.patch

"outcome" :
"success",

"result" : {}

This piece of code identifies a command to be executed within the application server’s Command
Line Interface (Using the CLI). Therefore, executing this command in the operating system’s shell
will obviously return an error.

5
This book is dedicated is lovingly dedicated to all people that helped me to find my verse in the
powerful play that’s life.

6
2. Getting started with WildFly
WildFly is a Java middleware product also known as application server. The word “application
server” has been coined in relation to Java Enterprise application; you can think of it as it’s a piece
of Java software where your application can be provisioned using the services provided by the
application server. Within this book you will learn how to configure these services, how to govern
them with authorization/authentication policies and how to extend the capabilities of the
application server.

Our journey through the application server will begin with the initial setup of your environment
and some basic administrative tasks. More in detail this chapter will cover the following topics:

• A brief introduction to the changes and enhancements introduced in WildFly

• How to install and verify the installation of the application server

• How to create a management user which will be in charge to handle server administration

• Installing the application server as a service using Windows or Linux environment

2.1. What is new in WildFly ?


WildFly 12 contains several enhancements over the AS7/EAP6 platform both in terms of
Administration and in terms of development API. These changes have been gradually incorporated
across the different versions of the application server. Let’s see a drill down of the changes which
happened in every server release:

2.1.1. Changes happened since WildFly 8

The first release of WildFly application server introduced several important changes from the
former JBoss AS 7 platform. Changes were equally split into the development area and into the
administration of the server. Here is a break down of the most significant news:

• Java EE 7 API support: The Java Enterprise API v. 7 has been fully integrated into the
application server. Some of the major enhancements included in the application server include:

• Java API for JSON Processing 1.0 (JSON-P): This API elevates the capabilities of JSON based
applications by defining a new API to parse, generate, transform and query JSON documents.
Therefore, you will be able to build a JSON object model (just like you did with DOM for XML
based applications) and consume them in a streaming fashion (as you did with XML using
StAX).

• Batch Application API 1.0: this API has been designed to standardize batch processing for Java
applications. You can think of it as a replacement for your older, bulk, long running procedures
that were managed by shell scripting or dated languages such as COBOL. The new Batch API
provides a rich programming model oriented to batch scripting which allows defining, partition
and forking the execution of jobs.

• Concurrency Utilities for Java EE 1.0: this API is an extension to the Java SE Concurrency
Utility (JSR-166) which aims to provide a simple and standard API for using Concurrency from
Java Enterprise components preserving the container integrity. This API can be used along with

7
asynchronous processing APIs in Servlets or for creating custom executors in advanced use
cases.

• Other API enhancements: besides the additions mentioned so far, there are further
enhancements in existing areas such the JAX-RS 2.0, which now includes a Client API for async
processing, a matching Server side asynchronous HTTP response and the addition of Filter and
Interceptors for proxying REST communications. Another area of improvement is the JMS 2.0
API, which now delivers a JMSContext resource as a wrapper for JMS Connection, Session and
Message Producer objects, and several enhancements such as the simplified ConnectionFactory
injection (which has finally a platform default) or the inclusion of delayed delivery and async
send. Other minor improvements are spread across the entire API (e.g. EJB 3.2, Servlet 3.1, EL
3.0, CDI 1.2 etc.). If you want to learn more details about it please consult the official Java EE 7
tutorial at: http://docs.oracle.com/javaee/7/tutorial/doc/

• Role Based Access Control: before WildFly 8, administrative users were not associated with a
particular role; in other words, once created a Management user then you were entitled to
perform any change to the server configuration like a classic super user. Now you can associate
each Management user with one role and even configure constraints, which allow you to tweak
the behavior of roles.

• New Web Server: WildFly has switched to a different Web Server implementation named
Undertow, which is the embedded Web server providing both blocking and non-blocking API
based on NIO. Besides the API enhancements, the Undertow Web server can provide better
flexibility thanks to its composition based architecture that allows you to build a Web server by
combining small single purpose handlers.

• Richer Management Interfaces: WildFly includes a richer set of management commands,


which have been added to the Command Line Interface such as the ability to patch the module
baseline, thus avoiding costly server installations in order to solve some issues. Also the Web
Administration Console has been greatly improved allowing a complete management of the
application server subsystem along with a comprehensive set of performance indicators.

• Simplified socket management: WildFly 8 reduced the number of ports by multiplexing


invocations over the HTTP channel; therefore, administrators and your security staff will spend
less time in setting up firewall policies.

2.1.2. Changes happened since WildFly 9

The release 9 of WildFly application server introduced several bug fixes and also some interesting
management enhancements in the platform. Here is the list of the most interesting ones:

• WebSocket 1.0: Before the advent of HTML 5, the traditional request-response model used in
HTTP meant that the client requested resources and the server provided responses. Therefore,
unless you are continuously polling the server, there is no way to way to provide dynamic
changes to your Web pages. The WebSocket protocol addresses these limitations by providing a
full-duplex communication channel between the client and the server without any latency
problem. Combined with other client technologies, such as JavaScript and HTML5, WebSocket
enables web applications to deliver a richer user experience.

• Front-end load balancer support: using an external Web server (like Apache) as load balancer
is now optional. Now you can configure WildFly’s web server (Undertow) to balance requests to
a cluster of WildFly servers through the mod_cluster protocol.

8
• Improved Datasource configuration: the datasource subsystem reflects the changes in the
pool policy introduced by IronJacamar Project 1.2.4 which contains a reworked set of policies
and a connection tracer to detect leaks in the pool.

• Improved Web console: The Web administration console includes a new improved UI layout
and several additional capabilities such as Datasource templates, enhanced subsystem
configuration or improved log viewer.

• CLI Suspend mode: It is now possible to put the application server in suspend mode, to allow
the termination of current sessions before shutting down the server. The suspend mode is
reversible so that is can also return the server in running mode.

• Offline management The Command Line interface allows the management of resources
without a running server.

• HTTP/2 Support: Undertow includes support for the new HTTP/2 standard which reduces
latency by compressing headers and multiplexing many streams over the same TCP connection.

2.1.3. Changes happened since WildFly 10

In this application server release a major restructuring began that will continue in the 1x releases.
These changes are both related to some single subsystems (such as the messaging subsystem) but
also to the whole server infrastructure. Expect some further changes in the 11 release of the
application server which will include a re-shaped security subsystem.

Here are the most significant changes in the release 10 of WildFly:

• New Messaging subsystem: the new messaging provider embedded in WildFly 10 is Apache
Artemis MQ which is derived from the HornetQ project, recently donated to the Apache
foundation. The new messaging provides retains compatibility with the former HornetQ while
providing several new features.

• Capabilities: Beginning with WildFly 10 the application server’s management layer includes a
mechanism for allowing different parts of the system to integrate with each other in a loosely
coupled manner. This happens thanks to a new component called “Capability”. Typically a
Capability works out by registering a service with the WildFly’s ServiceContainer, and then
dependent capabilities depend on that service. The WildFly Core management layer
orchestrates registration of those services and service dependencies by providing a means to
discover service names. Discussing about Capabilities is beyond the scope of this book.

• Improved ejb subsystem: the ejb pooling configuration has been revamped so that now it
includes multiple self-tuning policies applicable to Stateless EJB and to Message Driven Beans.
An advanced delivery policy (group based) can now be used by Message Driven Beans.

• Migration from legacy subsystems: an automatic CLI-based migration procedure has been
added to help users migrate the former legacy systems (jbossweb, messaging, jacorb) into
WildFly 10.

• Updated Hibernate API: the most relevant change for developers is the introduction of
Hibernate 5 API that includes several additional improvements spanning from performance
optimization (mainly due to bytecode enhancement), the use of generics in Hibernate Native,
and an improved SPI for second level cache providers. This topic, being focused on the
development of applications, is not in the scope of this book.

9
In terms of JDK, WildFly has discontinued support for Java 7. Hence, you need a
Java 8 or newer environment on your machine. If you are porting the former
 startup scripts, you have to replace the deprecated JVM parameter named
-XX:MaxPermSize with the new -XX:MaxMetaspaceSize.

2.1.4. Changes happened since WildFly 11

The release 11 of WildFly application server introduced several important changes spanning from
the new security infrastructure to simplified client naming lookup. This version includes also
several management enhancements to ease server administration. More in detail, this is a break
down of the latest significant news:

• New Security Infrastructure: a long awaited change is the new Security Provider named
Elytron which will be able to unify the whole security infrastructure in a single subsystem.
Elytron will bring also advanced capabilities such as privilege propagation across multiple
service invocations, pre-request TLS verification, identity switching, pre-request TLS
verification, and rich security policies. Finally it also improves the overall extensibility of the
system with tight integration with other SSO / IDP frameworks such as KeyCloak.

• SSL enhancements: You can switch from the JVM internal implementation of SSL to your own
OpenSSL library available on your system. This library can in turn be used (for versions greater
than 1.0.2) to support HTTP/2

• EJB made easier: several enhancements have been included to simplify the discover of EJB
resources thanks to a new naming library. Also the EJB naming proxies now allow more
advanced strategies such as dynamic discovery or point to point communication from proxies
to EJB.

• RMI over HTTP In order to allow load balancing of EJB request through a standard HTTP
request (which can be leveraged by any load balancer) you can now opt for a pure HTTP
communication for EJBs.

• New Load balancing Profile: If you are planning to use WildFly as front load balancer to a set
of WildFly backend, then you can use one out of the box configuration named standalone-load-
balancer.xml

• Graceful shutdown of the Server: the application server is now able to start in suspend mode
plus a set of improvements are available to handle distributed transactions when a graceful
shutdown has been issued.

• Management enhancements: a consistent number of enhancements have been added to the


Web console in many areas plus you the CLI tab completion shell is now able to complete
attributes, if a capability for it is available.

• Remote managed deployments: you are now able to update remote managed deployments by
including content items such as html or JSP files without a full application redeployment

2.1.5. Changes happened since WildFly 12

The 12th release of WildFly includes the following enhancements:

• Java EE 8 Profile: the application server includes now a Java EE8 configuration which can be

10
activated at start-up

• New thread pool trategy: A new thread pooling strategy is available. This allows reducing the
number of threads active at any given time, which helps conserve system resources.

• Other Minor enhancements: (MicroProfile REST Client 1.0 is now supported, Java 9
compatibility has been improved and CLI scripts can now take advantage of loops with
variables)

2.1.6. Changes happened since WildFly 13

The 13th release of WildFly includes provisioning enhancements for the application server and UI
upgrades along with some core libraries upgrades:

• Galleon project: WildFly can now be internally provisioned using the project Galleon which
allows to provision the desired installation at a specified location, install additional and/or
uninstall existing feature-packs, export the currently provisioned specification to a file with the
purpose to reproduce it on a different machine.

• New Web Console: a new version of the Web management console (HAL) is available which
uses PatternFly as technical stack instead of GWT. The new version of the Web console enhances
the existing features and adds support for many new subsystems and attributes.

• Other enhancements: Infinispan has been updated to version 9.2 and Hibernate to version 5.3.

2.1.7. Changes happened since WildFly 14

The 14th release of WildFly includes several enhancements. The most important one is the Java EE8
full compatibility so now all default configuration include the EE8 APIs. Additionally the following
enhancements have been included:

• Agroal Datasource: the application server can now be configured to use a JCA-less connection
pool with increased performance and low memory footprint.

• MicroProfile Capabilities: This version of the application server includes support for some
Eclipse MicroProfile capabilities such as the Configuration MicroProfile which enhances the
application’s configuration capabilities, a MicroProfile for Server Health checking and an API
for accessing an OpenTracing compliant Tracer object within your JAX-RS application.

• Mod-Cluster Multiplicity: Mod-cluster has now been enhanced to support multiple web server
configurations by declaring and referencing multiple mod-cluster configurations within its
subsystem.

2.2. Installing WildFly


The pre-requisite to the Application Server installation is that you have available a JDK on your
machine.

 It is recommended to use a JDK 9 or higher to start WildFly

The JDK can be either downloaded from Oracle site at


http://www.oracle.com/technetwork/java/javase/downloads/index.html or you can use an open

11
source implementation of it called OpenJDK http://openjdk.java.net/

Once installed the JDK, you have to set the JAVA_HOME environment variable accordingly.

Windows users: Right click on the My Computer icon on your desktop and select properties. Then
select the Advanced Tab contained in the Environment Variables button. Under System Variable,
click New. Enter the variable name as JAVA_HOME and value the Java install path. Click OK and
Click Apply Changes.

Linux users: Enter in your .profile / .bash_profile script the following (substitute with the actual
JDK installation path):

export JAVA_HOME=/usr/java/jdk-9

Done with JDK installation, let’s move to the application server. WildFly can be downloaded from
http://www.wildfly.org by following the Downloads link in the home page. Once downloaded,
extract the archive to a folder and you are done with the installation.

$ unzip wildfly-14.0.0.Final.zip

Through this book we will refer to JBOSS_HOME as the location where you have

 installed WildFly. As you will see later in this chapter, it is not however
mandatory to set this variable on your operating system to run WildFly.

2.3. An in-depth look into the application server file


system
After unzipping the application server, the following file structure will be available on your file
system:

12
As you can see, the WildFly file system is divided into two main parts: the first one, which is
pertinent to a standalone server mode and the other that is dedicated to domain server mode.
Common to both server modes is the modules directory, which is the heart of the application
server.

Following here are some details about the application server folders:

• appclient: contains configuration files, deployment content, and writable areas used by the
application client container run from this installation.

• bin: contains start up scripts, start-up configuration files and various command line utilities like
vault.sh, add-user.sh. Inside the client subfolder, you can find a client jar for use by non-maven
based clients. The other folders (service, init.d) are used respectively to install WildFly as a
Service on Windows and Linux machines.

• docs/schema: contains the XML schema definition files

• docs/examples/config: contains some sample standalone configurations (such as standalone-


minimalistic.xml).

• modules: contains all the modules installed on the application server.

• standalone: contains configuration files, deployment content, and writable areas (such as logs)
used by the single standalone server run from this installation.

• domain: contains configuration files, deployment content, and writable areas (such as logs)
used by the servers which are part of a domain.

• welcome-content: contains content related to the default (ROOT) web application.

13
2.4. Starting WildFly
The application server ships with two server modes: standalone and domain mode. The difference
between the two modes is not about the capabilities available but is related to the management of
the application server: in particular, the domain mode is used when you run several instances of
WildFly and you want a single point where you can manage servers and their configuration.

In order to start WildFly using the default configuration in "standalone" mode, change the directory
to $JBOSS_HOME/bin and issue:

$ ./standalone.sh

To start the application server using the default configuration in "domain" mode, change directory
to $JBOSS_HOME /bin and execute:

$ ./domain.sh

When starting in standalone mode, you should find in your console something like this, at the end
of start up process:

19:14:51,148 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http


management interface listening on http://127.0.0.1:9990/management
19:14:51,148 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console
listening on http://127.0.0.1:9990
19:14:51,149 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full
14.0.0.Final (WildFly Core 6.0.1.Final) started in 5615ms - Started 314 of 535
services (321 services are lazy, passive or on-demand)

You can verify that the server is reachable from the network by simply pointing your browser to
the application server’s welcome page, which is reachable by default at the following address:
http://localhost:8080

14
2.4.1. Setting the JBOSS_HOME

Although the application server has been renamed to WildFly, the home directory of it can still be
set through the JBOSS_HOME environment variable. Setting the JBOSS_HOME configuration
variable is not a mandatory step. By defining it in your bootstrap file (or in your user’s profile), you
are specifying the folder where WildFly distribution is located. The impact on your administration
is that you can use the standalone/domain startup script from a different location than the server
distribution. The reverse side of the coin is that this can lead to confusion your server
administrator especially if you have this variable buried in one of the many Linux configuration
files.

Whether you decide or not to set the JBOSS_HOME, here is how Linux users could set the variable
to point to a WildFly installation:

$ export JBOSS_HOME=/opt/wildfly-14.0.0.Final

On the other hand, Windows users can set the JBOSS_HOME as in this example:

set "JBOSS_HOME=/C:/jboss/wildfly-14.0.0.Final"

If you want to set the variable permanently on Windows, you have to go through

 your System Settings (In the Control Panel), click the Advanced System Settings
link and add the Environment Variable from there.

15
2.5. Your first task: Create an Administrator
If you want to manage the application server configuration using its management instruments, you
need to create a management user.

In order to create a new user, just execute the add-user.sh/add-user.bat, which is located in the
bin folder of the application server’s home. Here’s a transcript of the creation of a management
user:

$ ./add-user.sh
What type of user do you wish to add?
 a) Management User (mgmt-users.properties)
 b) Application User (application-users.properties)
(a): a

Enter the details of the new user to add.


Using realm 'ManagementRealm' as discovered from the existing property files.
Username : wildflyadmin
Password requirements are listed below. To modify these restrictions edit the add-
user.properties configuration file.
. . . .
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 'wildflyadmin' for realm 'ManagementRealm'


Is this correct yes/no? yes
Added user 'wildflyadmin' to file
'/home/jboss/wildfly-14.0.0.Final/standalone/configuration/mgmt-users.properties'
. . . .
Is this new user going to be used for one AS process to connect to another AS process?
e.g. for a slave host controller connecting to the master or for a Remoting connection
for server to server EJB calls.
yes/no? yes
To represent the user add the following to the server-identities definition <secret
value="RXJpY3Nzb24xIQ==" />

In the above example, we have created a management user named “wildflyadmin” which belongs
to the ManagementRealm and is not part of any group of users. Also, mind to answer the last
question with “yes” or “y” to indicate that the user will be used to connect to the domain controller
from the host controller. The generated secret value is the Base64-encoded password of the new
created user and we will use it when setting up a Domain of application servers.

In WildFly there is a strict control over your passwords. If you want to loosen or strengthen the
password checks, you can edit the add-user.properties file, which is contained in the bin folder of
your server distribution.

16
2.5.1. Creating an user in non-interactive mode

You can also create users using non-interactive mode. In the following example, we are adding a
management (-m flag) user by issuing:

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

If you need adding an application user, you need to include as well the -a flag as in the following
example, where we are setting as well a group to which the user belongs:

$ ./add-user.sh -a -u applicationuser1 -p password1! -g guest

Bear in mind that creating users in this way exposes your user credentials in the shell history and
maybe process table, if you are using a Linux/Unix machine.

2.6. Stopping WildFly


The simplest way to stop the application server is by sending an interrupt signal with Ctrl+C to the
server console. Linux/Unix users might as well have a look at the process table with the “ps”
command and issue a “kill” to stop the application server.

On the other hand, the recommended approach is to use the Command Line Interface (CLI)
interface to issue an immediate shutdown command. The CLI interface can be started from the
$JBOSS_HOME/bin folder of your installation:

$ ./jboss-cli.sh

Windows user will start the CLI using the equivalent batch file:

jboss-cli.bat

Once there, issue the connect command:

[disconnected /] connect

Connected to localhost:9990

Now issue the shutdown command that will stop the application server:

[localhost:9990 /] shutdown

You can optionally include the --restart=true parameter to trigger a server restart:

17
[standalone@localhost:9990/] shutdown --restart=true

Additionally, we will learn a first CLI trick that is executing a command in no-interactive mode. So
here is how to shut down the application server with a single command line:

$ ./jboss-cli.sh -c --command=shutdown

2.6.1. Stopping WildFly running on a remote host

If you are connecting to a remote WildFly instance, then a password will be requested when you
issue the CLI command:

[disconnected /] connect 192.168.10.1

Username: wildflyadmin
Password:

Connected to 192.168.10.1:9990

Once connected, we will issue the shutdown command just like we did from the local host:

[192.168.10.1:9990 /] shutdown

2.7. Handling start-up issues


A quite common cause of start-up issues is an existing service that is bindings the server ports. This
should be clearly evident from the server logs when you see this message:

18
15:15:14,738 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4)
MSC000001: Failed to start service
org.wildfly.undertow.listener.default:
org.jboss.msc.service.StartException in service
org.wildfly.undertow.listener.default: **Address already in use /127.0.0.1:8080
  at org.wildfly.extension.undertow.ListenerService.start(ListenerService.java:179)
  at
org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerIm
pl.java:1714)
  at
org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.ja
va:1693)
  at
org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.j
ava:1540)
  at
org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnabl
e.java:35)
  at
org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)
  at
org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.jav
a:1487)
  at
org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378
)
  at java.lang.Thread.run(Thread.java:745)

In this case, you should be able to find the service that is locking the ports used by the application
server which are by default the 8080 and the 9990. Most Unix systems have the built-in fuser
command that returns the process which is engaging a port :

$ fuser -v -n tcp 8080


PORT
USER PID ACCESS COMMAND
8080/tcp:
francesco 7148 F.... java

On Windows, you can use the netstat command to get network information about the running
processes.

C:>netstat -ao

Other common start up issue may happen if you have manually changed the configuration file, and
corrupted its XML schema. Manually changing the XML configuration file it is discourage, however
you can find the cause (and the line number) by searching through the startup logs:

19

Anda mungkin juga menyukai