table of contents - it buzz pressitbuzzpress.com/.../390/itbuzzpress-wildfly-admin-preview.pdf ·...

35

Upload: others

Post on 22-Jun-2020

12 views

Category:

Documents


1 download

TRANSCRIPT

Table of Contents1. 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 introduced in WildFly 8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  7

2.1.2. Changes introduced in WildFly 9 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  8

2.1.3. Changes introduced in WildFly 10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  9

2.1.4. Changes introduced in WildFly 11 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  10

2.1.5. Changes introduced in WildFly 12 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  10

2.1.6. Changes introduced in WildFly 13 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  11

2.1.7. Changes introduced in WildFly 14 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  11

2.1.8. Changes introduced in WildFly 15 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  11

2.1.9. Changes introduced in WildFly 16 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  12

2.2. Installing WildFly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  12

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

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

2.6.1. Stopping WildFly running on a remote host . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  19

2.7. Handling start-up issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  19

2.8. Installing WildFly as Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  21

2.8.1. Linux users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  21

2.8.1.1. Installing WildFly as a Service using init.d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  21

2.8.1.2. Installing WildFly as a Service using systemd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  23

2.8.2. Windows users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  23

3. Core Server configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  25

3.1. The two available server modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  25

3.2. Understanding the server configuration file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  26

3.2.1. Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  26

3.2.2. Paths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  27

3.2.3. Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  28

3.2.4. Socket binding groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  28

3.2.5. System-Properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  29

3.2.6. Profile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  30

3.3. Configuring WildFly in Standalone mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  30

3.3.1. Configuring JVM settings in Standalone Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  31

3.3.2. Configuring Network Interfaces in Standalone Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  31

3.3.3. Configuring Socket Bindings in Standalone Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  32

3.3.4. Configure Path references in Standalone Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  32

3.3.5. Configuring System Properties in Standalone Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  33

3.4. Configuring WildFly in Domain mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  33

3.4.1. Configuring the Domain Controller – Part 1: domain.xml . . . . . . . . . . . . . . . . . . . . . . . . . . . .  35

3.4.2. Configuring the Domain Controller – Part 2: host.xml . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  36

3.4.3. Configuring the Host Controllers (host.xml) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  36

3.4.4. Domain breakdown . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  39

3.5. Managing the WildFly Domain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  40

3.5.1. Mananaging the Domain Profiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  41

3.5.2. Mananaging the Domain Hosts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  41

3.5.2.1. Managing the Host controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  43

3.5.3. Managing the Server Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  44

3.6. Domain Controller Failover . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  44

3.6.1. Using Multiple Protocols to reconnect to the Domain Controller . . . . . . . . . . . . . . . . . . . . . .  46

3.6.2. Using Multiple Hosts in the Discovery Opions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  47

3.7. Standalone mode vs Domain mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  47

4. Server Management with Web console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  48

4.1. Connecting to the Web console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  48

4.2. Varying the Server Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  49

4.3. Gathering Runtime statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  50

4.4. Managing the Domain with the Console. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  52

4.4.1. Varying your Domain setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  53

4.4.2. Configuring Domain JVM Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  55

4.4.2.1. Configuring Host JVM Settings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  55

4.4.2.2. Configuring Server Groups JVM Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  56

4.4.2.3. Configuring Server JVM Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  57

4.5. Using the Web console’s Management Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  58

4.6. Admin Console or not ?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  59

5. Server Management with the CLI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  61

5.1. Starting the Command Line. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  61

5.1.1. Recovering your server configuration using the CLI. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  62

5.2. Using the CLI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  62

5.3. Build up the CLI commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  64

5.3.1. Determine the resource address. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  64

5.3.2. Reading attributes of resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  64

5.3.3. Writing attributes of resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  65

5.3.4. Adding new resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  65

5.3.5. Reading children resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  66

5.3.6. Extra operations available on resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  67

5.4. Detecting active operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  67

5.5. Tracing CLI commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  69

5.5.1. In-memory configuration changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  69

5.6. Running the CLI in graphical mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  69

5.6.1. Adding resources in graphical mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  71

6. Advanced CLI features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  72

6.1. Using CLI batch mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  72

6.1.1. More about batch commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  73

6.2. Using batch deployments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  74

6.3. Applying patches to your configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  75

6.4. Taking snapshots of your configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  77

6.5. Running the CLI in offline mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  79

6.6. Suspending and resuming the Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  80

6.7. Graceful shutdown of the Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  82

6.8. Conditional execution with the CLI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  82

6.9. Migration of legacy systems with the CLI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  83

7. Deploying applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  85

7.1. File system deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  85

7.1.1. Mode 1: Auto-deploy mode: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  85

7.1.2. Mode 2: Manual deploy mode: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  85

7.1.3. Configuring the Deployment scanner attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  86

7.2. Deploying using the Web interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  87

7.2.1. Standalone Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  87

7.2.2. Domain Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  89

7.2.2.1. Managing your application status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  92

7.3. Deploying the application using the CLI. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  93

7.3.1. Manipulating exploded deployments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  94

7.3.2. Listing the module dependencies of a deployed application. . . . . . . . . . . . . . . . . . . . . . . . . .  94

7.3.3. CLI Domain deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  96

7.4. Deploying applications using Maven . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  96

7.4.1. Domain Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  97

8. Configuring Database connectivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  98

8.1. Creating a Datasource using the CLI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  99

8.1.1. Creating a Datasource in Domain mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  100

8.1.2. Creating an XA Datasource . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  100

8.1.2.1. Enabling XA transactions on the DB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  101

8.2. Configuring a Datasource using the Admin Console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  102

8.3. Deploying a Datasource as a resource . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  106

8.3.1. Packaging Datasources in your applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  107

8.4. Configuring Datasources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  108

8.4.1. Configuring the Datasource pool attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  108

8.4.2. Configuring flush strategies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  109

8.4.3. Protecting a Datasource credentials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  110

8.4.3.1. Step 1: Generate the encrypted password . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  110

8.4.3.2. Step 2: Create the Security Domain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  110

8.4.3.3. Step 3: Let your datasource use the Security Domain: . . . . . . . . . . . . . . . . . . . . . . . . . .  111

8.4.4. Masking your Datasource credentials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  112

8.4.5. Using System Properties in your deployable data sources . . . . . . . . . . . . . . . . . . . . . . . . . .  112

8.4.6. Configuring Multi Datasources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  113

8.5. Policies for creating/destroying connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  113

8.5.1. Configuring the incrementer capacity policy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  114

8.5.2. Configuring the decrementer capacity policy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  115

8.6. Gathering runtime statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  116

8.6.1. Detecting leaked connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  118

8.7. Configuring Agroal Datasource . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  119

8.7.1. Creating an Agroal XA Datasource . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  120

9. Configuring Undertow Webserver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  122

9.1. Entering Undertow Web server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  122

9.2. Configuring Undertow Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  123

9.2.1. Adding a connection limit filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  124

9.2.2. Adding a gzip filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  124

9.2.3. Adding an error filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  124

9.2.4. Adding a custom filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  125

9.3. Configuring Undertow Handlers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  125

9.3.1. Configuring a File based Handler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  126

9.3.2. Creating a Reverse Proxy Handler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  127

9.4. Configuring Undertow Listeners . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  128

9.4.1. Configuring the Web server Pool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  129

9.4.2. Configuring a custom Worker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  130

9.4.3. Other listeners attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  131

9.5. Configuring Undertow Buffer Pool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  132

9.6. Configuring Virtual Hosts in Undertow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  133

9.7. Configuring the Servlet Container and JSP Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  135

9.8. Gathering statistics about Web applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  138

9.9. Configuring HTTP/2 Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  139

9.10. Configuring EJB calls over Undertow’s HTTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  139

10. Configuring the EJB Container . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  141

10.1. Configuring the EJB Pools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  141

10.2. Configuring the MDB delivery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  143

10.2.1. Configuring MDB Group delivery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  144

10.2.1.1. Attaching an MDB to multiple Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  144

10.3. Configuring the Stateful Session Bean cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  145

10.3.1. Enabling Passivation for Stateful Session Beans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  146

10.3.2. Disabling Passivation for a single deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  147

10.3.3. Setting the Access timeout for SFSBs and Singleton beans . . . . . . . . . . . . . . . . . . . . . . . . .  148

10.4. EJB3 Thread pool configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  148

10.4.1. Configuring the EJB thread pool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  149

10.4.2. Gathering runtime statistics of the thread pool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  150

10.4.3. Configuring Remote EJB Transport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  151

10.4.4. Enabling statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  152

10.4.5. Configuring a different Resource Adapter for your MDBs . . . . . . . . . . . . . . . . . . . . . . . . .  153

11. Configure Logging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  156

11.1. WildFly default logging configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  156

11.2. Configuring Log Handlers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  157

11.2.1. Configuring the Periodic Rotating Handler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  157

11.2.1.1. Changing the path where the log is written . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  158

11.2.1.2. Formatting the log output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  159

11.2.1.3. Filtering the logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  159

11.2.2. Adding a new Handler: the Size Rotating Handler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  160

11.2.2.1. Adding the handler from the Web console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  160

11.2.2.2. Adding the handler from the CLI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  161

11.2.3. Creating a Custom Handler that writes logs to the Database . . . . . . . . . . . . . . . . . . . . . . .  161

11.2.4. Creating a Custom Handler that writes logs via Socket . . . . . . . . . . . . . . . . . . . . . . . . . . . .  162

11.2.5. Configuring Handlers to be asynchronous . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  163

11.3. Configuring the Root Logger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  164

11.4. Configuring Logging Categories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  165

11.5. Other Logging configuration files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  166

11.5.1. Using Log4j to trace your application logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  166

11.5.2. Disabling the core logging API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  167

11.6. Other ways to read the log files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  167

11.6.1. Reading Logs with the Command Line Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  167

11.6.2. Reading logs using the HTTP channel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  168

12. Configuring JMS Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  169

12.1. ActiveMQ Artemis overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  169

12.1.1. Artemis ActiveMQ architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  169

12.1.2. Socket Management in ActiveMQ Artemis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  170

12.1.3. Starting WildFly with JMS Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  171

12.2. Configuring JMS Connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  172

12.2.1. Additional properties you can set on Connectors and Acceptors . . . . . . . . . . . . . . . . . . .  173

12.2.2. Switching to Netty sockets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  174

12.3. Creating JMS Destinations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  175

12.3.1. Built-in Queues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  178

12.3.2. Creating Queues and Topics using the Command Line Interface . . . . . . . . . . . . . . . . . . .  178

12.3.2.1. Creating deployable JMS destinations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  178

12.3.3. Customizing JMS destinations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  179

12.4. Configuring Message Persistence. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  181

12.4.1. Configuring File system journal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  181

12.4.1.1. Changing the location where the Journal is persisted. . . . . . . . . . . . . . . . . . . . . . . . . .  182

12.4.1.2. Configuring Journal’s Max Disk Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  183

12.4.1.3. Configuring Message Paging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  183

12.4.1.4. Configuring the paging folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  184

12.4.2. Configuring JDBC Storage for messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  184

12.4.2.1. Varying the default Journal Table Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  185

12.5. Routing Messages to other destinations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  186

12.5.1. Diverting messages to other destinations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  186

12.5.2. Creating a Bridge between two ActiveMQ Artemis servers . . . . . . . . . . . . . . . . . . . . . . . . .  187

12.5.2.1. ActiveMQ Artemis target configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  188

12.5.2.2. ActiveMQ Artemis source configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  188

12.5.2.3. Bridging messages to another JMS Broker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  191

12.6. JMS Clustering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  191

12.6.1. HA with Shared Store . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  192

12.6.2. HA with data replication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  192

12.6.3. Cluster core configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  193

12.6.4. Server Discovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  195

12.6.4.1. Broadcast Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  195

12.6.4.2. Discovery Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  196

12.6.5. Starting your cluster of Artemis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  197

12.6.6. Configuring a static discovery of cluster nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  197

13. Classloading and modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  199

13.1. What are modules ? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  199

13.2. Configuring static modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  200

13.2.1. How to install a new module. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  200

13.2.1.1. Example: How to install Jython library as a module . . . . . . . . . . . . . . . . . . . . . . . . . . .  201

13.2.1.2. How to use an installed module in your application . . . . . . . . . . . . . . . . . . . . . . . . . . .  202

13.2.1.3. How to turn your modules in a global module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  202

13.2.1.4. How to deploy extension-type dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  203

13.3. Configuring dynamic modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  203

13.3.1. How to use dynamic modules in your applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  203

13.4. Configuring module Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  204

13.4.1. Implicit dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  204

13.4.2. Explicit dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  205

13.5. Advanced Classloading policies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  206

13.5.1. How to prevent your modules from being loaded . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  207

13.5.2. How to prevent a subsystem from being loaded . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  208

13.5.3. Configuring classloading isolation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  209

13.5.4. Sticking to Java EE compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  210

13.6. Provisioning WildFly using Galleon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  210

13.6.1. Getting started with Galleon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  211

13.6.2. Exploring Galleon command line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  212

13.6.3. Installing different versions of a feature-pack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  213

13.6.4. Choosing the layers to include in the installations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  214

14. Clustering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  216

14.1. WildFly clustering building blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  216

14.2. Clustering standalone nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  217

14.2.1. Clustering standalone servers on different machines . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  217

14.2.2. Clustering standalone servers on the same machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  217

14.3. Configuring a cluster of domain nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  218

14.3.1. Enabling clustering services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  219

14.4. Configuring the Cluster transport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  220

14.4.1. Changing the Protocol Stack used by JGroups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  221

14.4.2. Configuring a full TCP stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  222

14.4.2.1. Legacy tcpping configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  223

14.4.3. Other JGroups stacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  224

14.4.4. Configuring the Transport Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  226

14.4.5. Configuring the Protocol Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  227

14.5. Configuring Clustering Caches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  228

14.5.1. Configuring the Cache Container top level attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  229

14.5.2. Configuring the Cache Container Transport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  231

14.6. Configuring ejb and web Cache containers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  232

14.6.1. Configuring a Replicated cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  232

14.6.1.1. Creating a replicated cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  233

14.6.2. Configuring a Distributed cache. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  233

14.6.2.1. Providing hints to the Distributed cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  234

14.6.2.2. Adding L1 cache to a distributed cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  234

14.6.3. Configuring ejb and web Cache containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  235

14.6.3.1. Configuring cache eviction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  235

14.6.3.2. Configuring cache expiration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  236

14.6.3.3. Configuring locking for entries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  236

14.6.3.4. Configuring EJB and Web application cache Storage . . . . . . . . . . . . . . . . . . . . . . . . . .  238

14.6.3.5. Using a JDBC Cache store . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  239

14.6.3.6. Example: Defining a JDBC Cache Store . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  239

14.6.4. Controlling Passivation of HTTP Sessions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  240

14.7. Configuring hibernate Cache Container . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  240

14.7.1. Configuring Hibernate cache for Entities and Collections . . . . . . . . . . . . . . . . . . . . . . . . . .  241

14.7.1.1. Configuring eviction for hibernate cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  242

14.7.1.2. Configuring expiration for hibernate cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  242

14.7.1.3. Configuring locking for hibernate cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  243

14.7.1.4. Configuring Hibernate cache for queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  244

14.7.1.5. Configuring the Timestamp cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  244

15. Load balancing applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  246

15.1. Configuring Apache mod_jk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  246

15.1.1. Configuring Apache Web server side . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  246

15.1.2. Configuring WildFly to receive AJP requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  248

15.2. Configuring mod_cluster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  249

15.2.1. Installing mod_cluster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  249

15.2.2. Configuring WildFly for mod_cluster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  250

15.2.3. Testing your configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  251

15.2.4. A deep look into mod_cluster configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  252

15.2.5. Troubleshooting mod_cluster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  254

15.2.5.1. Check multicast communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  255

15.2.5.2. Switch additional display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  256

15.3. Advanced mod_cluster configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  256

15.3.1. Using a static list of http proxies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  257

15.3.2. How to configure mod_cluster to exclude one Web context . . . . . . . . . . . . . . . . . . . . . . . .  257

15.3.3. Configuring Sticky Sessions with mod_cluster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  257

15.3.4. Configuring Metrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  258

15.3.4.1. Configuring Initial Load . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  260

15.4. Configuring HA for remote EJB clients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  260

15.5. Undertow as mod_cluster Front end. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  262

15.5.1. Configuring the Back end. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  262

15.5.2. Configuring the Front end . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  262

15.5.2.1. Manually configuring the Undertow filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  263

15.5.2.2. Testing Undertow’s mod_cluster load balancer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  264

15.6. Mod-Cluster Multiplicity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  265

16. Securing WildFly with Elytron . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  268

16.1. Elytron building blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  268

16.1.1. Default Security Domain and Security Realms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  269

16.2. How to enable Elytron for Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  270

16.3. Elytron Realms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  271

16.3.1. Configuring a File System Security Realm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  272

16.3.1.1. Testing Elytron Security Realm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  273

16.3.1.2. Using other options for storing the password . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  274

16.3.1.3. Using Elytron in parallel with the Legacy security subsystem . . . . . . . . . . . . . . . . . .  275

16.3.2. Converting legacy property files into Elytron FileSystemRealm . . . . . . . . . . . . . . . . . . . .  275

16.3.2.1. Using the Elytron tool against a Descriptor File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  276

16.3.3. Configuring a JDBC Realm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  276

16.3.4. Configuring an LDAP Realm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  278

16.3.5. Configuring a SASL Based Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  281

16.3.5.1. Configuring the EJB Server side . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  282

16.3.5.2. Configuring the EJB Client side . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  283

16.4. Securing Management interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  284

16.5. Configuring SSL/TSL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  284

16.5.1. Creating your own certificates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  285

16.5.2. Configuring One-Way SSL / HTTPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  287

16.5.3. Configuring Mutual SSL Authentication. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  289

16.5.4. Importing Client certificates on your browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  290

16.5.5. Configuring OpenSSL as SSL provider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  291

16.6. Configuring Server Name Indication (SNI) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  292

16.7. Configuring Java Authentication Service Provider Interface (JASPI) . . . . . . . . . . . . . . . . . . . .  293

16.8. Using Credential Stores to store sensitive data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  294

16.8.1. Example: securing your Datasource password . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  294

16.8.2. Configuring the Credential Store Offline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  295

17. WildFly’s legacy security model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  296

17.1. Security building blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  296

17.1.1. Configuring Security Realms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  296

17.1.1.1. The Management Realm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  297

17.1.1.2. The Application Realm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  297

17.2. WildFly Security Domains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  298

17.2.1. Security under the hood . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  299

17.2.2. Using the RealmDirect login module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  300

17.2.2.1. Adding new Application users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  301

17.2.2.2. Defining the roles into your applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  302

17.2.3. Database Login module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  304

17.2.3.1. Using encrypted database passwords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  305

17.2.4. LDAP Login module configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  306

17.2.5. Login not working? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  307

17.2.6. Auditing Security Domains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  308

17.3. Management Security with Login Modules. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  309

17.4. Management Security with LDAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  309

17.5. Introducing Java EE 8 API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  310

17.5.1. Secure web authentication with Java EE 8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  310

17.5.2. Managing Identity Stores with Java EE 8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  313

17.6. Enabling the Secure Socket Layer on WildFly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  314

17.6.1. Securing Web applications with SSL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  315

17.6.1.1. How to secure the application server with a CA signed certificate . . . . . . . . . . . . . .  317

17.7. Encrypting the Management Interfaces channel. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  318

17.8. WildFly support for HTTP/2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  318

17.8.1. Setting up HTTP/2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  319

18. RBAC and other Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  321

18.1. Configuring Role Based Access Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  321

18.1.1. Enabling RBAC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  322

18.1.2. Using groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  326

18.1.3. Defining Scoped Roles for Domain mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  328

18.1.3.1. Server Group-scoped roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  329

18.1.3.2. Host-scoped roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  330

18.1.4. Configuring Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  331

18.1.4.1. Configuring Sensitivity Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  331

18.1.4.2. Configuring Application Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  333

18.2. Configuring Security Manager on WildFly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  335

18.2.1. Running WildFly with a Security Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  335

18.2.2. Coding Permissions in the configuration file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  336

18.2.3. Restricting permissions at module level . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  337

19. Taking WildFly in the cloud . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  339

19.1. Getting Started with Docker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  339

19.1.1. Main components of Docker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  340

19.1.1.1. Installing Docker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  340

19.2. Running your first Docker image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  342

19.3. Running WildFly images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  343

19.4. Extending WildFly’s image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  345

19.4.1. Deploying applications on Docker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  346

19.5. Getting started with OKD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  347

19.5.1. Installing Minishift . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  347

19.5.1.1. Starting Minishift cluster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  348

19.5.2. Openshift cheat sheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  348

19.6. Deploying WildFly on OKD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  349

19.7. Customizing the database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  353

20. Configuring MicroProfile capabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  360

20.1. Configuring the MicroProfile Config . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  360

20.1.1. ConfigSources in microprofile-config-smallrye subsystem . . . . . . . . . . . . . . . . . . . . . . . . .  361

20.1.2. ConfigSource from Class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  363

20.1.3. ConfigSources in microprofile-config.properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  365

20.2. Configuring Microprofile health . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  366

20.2.1. Management Health check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  366

20.2.2. HTTP Endpoint Health check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  366

20.2.3. Beans Health Check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  367

20.3. Configuring MicroProfile OpenTracing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  367

20.4. The Metrics subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  370

20.4.1. Securing the metrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  372

21. Appendix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  373

21.1. The singleton subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  373

21.1.1. Defining a Quorum for Singleton . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  374

21.2. The naming subsystem. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  374

21.2.1. Naming Alias . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  375

21.3. The batch-jberet subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  375

21.4. The mail subsystem. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  377

1. WildFly Administration GuideAuthor : Francesco Marchioni

© ItBuzzPress 2019

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

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

I was very pleased to hear that Francesco was planning to write a book on WildFly 8. High qualitybooks like this one are critical to the success of open source software, and Francesco has theexpertise 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’sweb console and its command line interface (CLI) administration tool are well covered, as are all ofthe key areas of application server administration. This book definitely belongs on the bookshelf ofanyone administering WildFly or developing application for it.

Brian Stansberry

1.2. PrefaceWildFly is the continuation of the release cycle of the application server community edition, whichwas 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 morethan one reason for this change, the first one being to avoid confusion between the commonlyreferred community version (JBoss AS) and the Enterprise version supported by Redhat. Besidesthis, 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 meanthe application server sometimes else to mean a brand of products.

The rename applies, however, only for the JBoss Application Server community edition. Thelicensed 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 projectand specifically the application server project.

Besides the new brand name, the WildFly application server follows the same path traced by JBossAS 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 EEtechnology, offering richer management capabilities, a more advanced security control and someimportant updates as well in the Web server tier.

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

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

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

1.3. The Author of the BookFrancesco Marchioni is a Quality Engineer working at Red Hat since 2014. He has joined the JBosscommunity in early 2000 when the application server was a mere EJB container, running release2.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 Worldwhich covers in an earthy and rational style the discussion about the Simulation Hypothesis.

1.4. The reviewersJaikiran Pai works at Red Hat and is part of the JBoss AS and EJB3 development team. In his role asa 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 aninterest 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-authorsof JBoss AS Getting Started DZone RefCard http://refcardz.dzone.com/refcardz/getting-started-jboss.

1.5. What this book coversChapter 1, Installing WildFly covers the installation of the server platform and introduces thereader to the most significant changes brought through the releases 8, 9 and 10 of the applicationserver

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

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

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

Chapter 5, Advanced CLI features covers some advanced tasks that can be pursued with the CLIsuch 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 JavaEnterprise applications on the application server.

Chapter 7, Database connectivity, is about configuring connections to relational databases byinstalling JDBC Drivers and Datasources.

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

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

Chapter 10, Configuring Logging covers the configuration of log subsystem, including all availablelog 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 nowActiveMQ 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. The chapter alsocovers the Galleon tool and how it can be used to provision custom versions of the applicationserver.

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

Chapter 14, Load Balancing Web Applications discusses the other key concern of clustering, thatis 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 frameworkusing the Legacy Security Framework

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

Chapter 18, Taking WildFly in the cloud shows how to deploy the application server in the cloud,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 containerenvironments.

1.5.1. Who this book is for

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

1.5.2. How to Contact Us

Please address comments and questions concerning this book to the publisher:[email protected]. 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 thecontent copyright holder is strictly forbidden. Piracy is an illegal act that you may aspire toreconsider. Besides this, piracy is not a victimless crime! It is financially damaging and personallyhurtful to company employees and their families. Legitimate users suffer as well. We appreciate

4

your help in protecting the valuable content of this book.

1.5.4. Book Version

This is the version 1.6 of the book – Updated 13 March 2019

1.5.5. Conventions used in this book

This book contains lots of script files and commands to be executed on your machine. Much efforthas 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 youroperating system’s shell:

$ ./jboss-cli.sh

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

C:\Users\jboss\wildfly-16.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 CommandLine Interface (Using the CLI). Therefore, executing this command in the operating system’s shellwill obviously return an error.

5

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

6

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

Our journey through the application server will begin with the initial setup of your environmentand 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 ?This chapter contains all the changes which have been incorporated in WildFly up to the latestrelease. It contains the enhancements provided in each server release so that you can plan easily'diff' the changes from one release to another.

2.1.1. Changes introduced in WildFly 8

The first release of WildFly application server introduced several important changes from theformer JBoss AS 7 platform. Changes were equally split into the development area and into theadministration 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 theapplication 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 basedapplications 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 XMLbased applications) and consume them in a streaming fashion (as you did with XML usingStAX).

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

• Concurrency Utilities for Java EE 1.0: this API is an extension to the Java SE ConcurrencyUtility (JSR-166) which aims to provide a simple and standard API for using Concurrency fromJava Enterprise components preserving the container integrity. This API can be used along withasynchronous processing APIs in Servlets or for creating custom executors in advanced use

7

cases.

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

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

• New Web Server: WildFly has switched to a different Web Server implementation namedUndertow, which is the embedded Web server providing both blocking and non-blocking APIbased on NIO. Besides the API enhancements, the Undertow Web server can provide betterflexibility thanks to its composition based architecture that allows you to build a Web server bycombining 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 modulebaseline, thus avoiding costly server installations in order to solve some issues. Also the WebAdministration Console has been greatly improved allowing a complete management of theapplication server subsystem along with a comprehensive set of performance indicators.

• Simplified socket management: WildFly 8 reduced the number of ports by multiplexinginvocations over the HTTP channel; therefore, administrators and your security staff will spendless time in setting up firewall policies.

2.1.2. Changes introduced in WildFly 9

The release 9 of WildFly application server introduced several bug fixes and also some interestingmanagement 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 inHTTP 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 dynamicchanges to your Web pages. The WebSocket protocol addresses these limitations by providing afull-duplex communication channel between the client and the server without any latencyproblem. Combined with other client technologies, such as JavaScript and HTML5, WebSocketenables web applications to deliver a richer user experience.

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

8

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

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

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

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

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

2.1.3. Changes introduced in 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) butalso to the whole server infrastructure. Expect some further changes in the 11 release of theapplication 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 ApacheArtemis MQ which is derived from the HornetQ project, recently donated to the Apachefoundation. The new messaging provides retains compatibility with the former HornetQ whileproviding several new features.

• Capabilities: Beginning with WildFly 10 the application server’s management layer includes amechanism for allowing different parts of the system to integrate with each other in a looselycoupled manner. This happens thanks to a new component called "Capability". Typically aCapability works out by registering a service with the WildFly’s ServiceContainer, and thendependent capabilities depend on that service. The WildFly Core management layerorchestrates registration of those services and service dependencies by providing a means todiscover 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 itincludes 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 beenadded to help users migrate the former legacy systems (jbossweb, messaging, jacorb) intoWildFly 10.

• Updated Hibernate API: the most relevant change for developers is the introduction ofHibernate 5 API that includes several additional improvements spanning from performanceoptimization (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 thedevelopment 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 aJava 8 or newer environment on your machine. If you are porting the formerstartup scripts, you have to replace the deprecated JVM parameter named-XX:MaxPermSize with the new -XX:MaxMetaspaceSize.

2.1.4. Changes introduced in WildFly 11

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

• New Security Infrastructure: a long awaited change is the new Security Provider namedElytron 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 multipleservice invocations, pre-request TLS verification, identity switching, pre-request TLSverification, and rich security policies. Finally it also improves the overall extensibility of thesystem 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 ownOpenSSL library available on your system. This library can in turn be used (for versions greaterthan 1.0.2) to support HTTP/2

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

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

• New Load balancing Profile: If you are planning to use WildFly as front load balancer to a setof 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 modeplus a set of improvements are available to handle distributed transactions when a gracefulshutdown has been issued.

• Management enhancements: a consistent number of enhancements have been added to theWeb console in many areas plus you the CLI tab completion shell is now able to completeattributes, if a capability for it is available.

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

2.1.5. Changes introduced in 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 thenumber of threads active at any given time, which helps conserve system resources.

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

2.1.6. Changes introduced in WildFly 13

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

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

• New Web Console: a new version of the Web management console (HAL) is available whichuses PatternFly as technical stack instead of GWT. The new version of the Web console enhancesthe 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 introduced in 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 thefollowing enhancements have been included:

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

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

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

2.1.8. Changes introduced in WildFly 15

The 15th release of the application server contains some additions for monitoring the applicationserver and some global HTTPS and SSL enhancements. More in detail:

• New metrics subsystem: The application server development is happening with a view tocontainers. In order to observe the application server (or fraction of it) in a containerenvironment it is crucial to gather metrics. The new 'metrics' subsystem allows to collectWildFly and application metrics and make available to monitoring systems like Prometheus.

11

• SNI Support for HTTPS Listeners: Java 8 has introduced for server side SNI support, which is afeature that extends the SSL/TLS protocols to indicate what server name the client is attemptingto connect to during handshaking. Now we can configure Undertow with more than 1 virtualservers and users are able to use a different server certificate for each virtual server.

• Support for registering a single JVM / Server wide default SSLContext: by registering aglobal SSLContext libraries used within the application server can make use of a managedSSLContext instead of relying on one automatically being created through the standard systemproperties.

• JASPI Integration with Elytron: The Elytron subsystem now contains the configurationrequired to support JASPI to the Elytron subsystem and general JASPI integration.

2.1.9. Changes introduced in WildFly 16

The 16th release of the application server continues its path towards a more agile applicationserver, with further improvements in the Galleon tool, to provide customized version, withminimal memory foot-print, of the application server. Some other notable items:

• Messaging subystem improvements: You can configure MDBs to join multiple delivery groups,enabling delivery when all groups are active. You can now reference remote Artemis serversthrough Java EE 8 resource definitions. Finally, you can impose a limit on the amount of diskspace used by the artemis journal.

• Clustering Improvements : The load balancer can now configured to use a ramp up periodbefore allowing the maximum traffic. Other minor improvements in the HA Singletondeployments have been added as well.

• Other Improvements : The command line has been enriched with a command to list moduleslinked by a deployed applications. It is also possible to query for long-running managementoperations and stop potentially locked operations. Some minor improvements have been addedalso in Elytron such as 'silent mode' for HTTP Basic authentication mechanism and an utilityscript to migrate legacy properties files to Elytron.

2.2. Installing WildFlyThe pre-requisite to the Application Server installation is that you have available a JDK on yourmachine.

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

The JDK can be either downloaded from Oracle site athttp://www.oracle.com/technetwork/java/javase/downloads/index.html or you can use an opensource 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. Thenselect 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 andClick Apply Changes.

12

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

export JAVA_HOME=/usr/java/jdk-9

Done with JDK installation, let’s move to the application server. WildFly can be downloaded fromhttp://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-16.0.0.Final.zip

Through this book we will refer to JBOSS_HOME as the location where you haveinstalled WildFly. As you will see later in this chapter, it is not howevermandatory to set this variable on your operating system to run WildFly.

2.3. An in-depth look into the application server filesystemAfter unzipping the application server, the following file structure will be available on your filesystem:

As you can see, the WildFly file system is divided into two main parts: the first one, which ispertinent to a standalone server mode and the other that is dedicated to domain server mode.

13

Common to both server modes is the modules directory, which is the heart of the applicationserver.

Following here are some details about the application server folders:

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

• bin: contains start up scripts, start-up configuration files and various command line utilities likevault.sh, add-user.sh. Inside the client subfolder, you can find a client jar for use by non-mavenbased clients. The other folders (service, init.d) are used respectively to install WildFly as aService 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.

2.4. Starting WildFlyThe application server ships with two server modes: standalone and domain mode. The differencebetween the two modes is not about the capabilities available but is related to the management ofthe application server: in particular, the domain mode is used when you run several instances ofWildFly 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 directoryto $JBOSS_HOME/bin and issue:

$ ./standalone.sh

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

$ ./domain.sh

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

14

19:14:51,148 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Httpmanagement interface listening on http://127.0.0.1:9990/management19:14:51,148 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin consolelistening on http://127.0.0.1:999019:14:51,149 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full16.0.0.Final (WildFly Core 8.0.0.Final) started in 5615ms - Started 314 of 535services (321 services are lazy, passive or on-demand)

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

2.4.1. Setting the JBOSS_HOME

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

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

15

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

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

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

If you want to set the variable permanently on Windows, you have to go throughyour System Settings (In the Control Panel), click the Advanced System Settingslink and add the Environment Variable from there.

2.5. Your first task: Create an AdministratorIf you want to manage the application server configuration using its management instruments, youneed 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 thebin folder of the application server’s home. Here’s a transcript of the creation of a managementuser:

16

$ ./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 : wildflyadminPassword 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? yesAdded user 'wildflyadmin' to file'/home/jboss/wildfly-16.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 connectionfor server to server EJB calls.yes/no? yesTo represent the user add the following to the server-identities definition <secretvalue="RXJpY3Nzb24xIQ==" />

In the above example, we have created a management user named "wildflyadmin" which belongsto the ManagementRealm and is not part of any group of users. Also, mind to answer the lastquestion with "yes" or "y" to indicate that the user will be used to connect to the domain controllerfrom the host controller. The generated secret value is the Base64-encoded password of the newcreated 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 thepassword checks, you can edit the add-user.properties file, which is contained in the bin folder ofyour server distribution.

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 amanagement (-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

17

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 andmaybe process table, if you are using a Linux/Unix machine.

2.6. Stopping WildFlyThe simplest way to stop the application server is by sending an interrupt signal with Ctrl+C to theserver 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:

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

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

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

18

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 youissue the CLI command:

[disconnected /] connect 192.168.10.1

Username: wildflyadminPassword:

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 issuesA quite common cause of start-up issues is an existing service that is bindings the server ports. Thisshould be clearly evident from the server logs when you see this message:

19

15:15:14,738 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4)MSC000001: Failed to start serviceorg.wildfly.undertow.listener.default:org.jboss.msc.service.StartException in serviceorg.wildfly.undertow.listener.default: **Address already in use /127.0.0.1:8080  at org.wildfly.extension.undertow.ListenerService.start(ListenerService.java:179)  atorg.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1714)  atorg.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1693)  atorg.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1540)  atorg.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)  atorg.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)  atorg.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)  atorg.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 applicationserver which are by default the 8080 and the 9990. Most Unix systems have the built-in fusercommand that returns the process which is engaging a port :

$ fuser -v -n tcp 8080PORTUSER PID ACCESS COMMAND8080/tcp:francesco 7148 F.... java

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

C:>netstat -ao

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

20

OPVDX001: Validation error in standalone.xml -------------------------------| 34: <management>| 35: <security-realms>xx| 36: <security-realm name="ManagementRealm">| ^^^^ Received non-all-whitespace CHARACTERS or CDATA event in nextTag()|| 37: <authentication>| 38: <local default-user="$local" skip-group-loading="true"/>| 39: <properties path="mgmt-users.properties" relative-to="jboss.server.config.dir"/>|| The primary underlying error message was:| > Received non-all-whitespace CHARACTERS or CDATA event in nextTag().| > at [row,col {unknown-source}]: [36,12]

2.8. Installing WildFly as ServiceWildFly can be as well installed as a service and allowed to be started at boot time. In order to dothat, you need to use some script files, which are contained within the server. The next two sections(one for Linux users and one for Windows users) discuss about it:

2.8.1. Linux users

In order to start an application as a service on Linux you can use two main approaches:

• Use the init.d daemon

• Use the systemd daemon

The application server is no exception to it so let’s see how to install it as a service using bothapproaches.

2.8.1.1. Installing WildFly as a Service using init.d

The init daemon is the older approach which is however available in all Linux Distributions. Thescripts which are needed to install WildFly as a service are located under the$JBOSS_HOME/docs/contrib/scripts/init.d folder. If you look into this folder, you will find thefollowing files:

• wildfly-init-redhat.sh: this file needs to be used for Red Hat Enterprise-like Linux distributions(e.g. RHEL, Centos)

• wildfly-init-debian.sh: this file needs to be used for Debian-like Linux distributions (e.g.Debian, Ubuntu)

• wildfly.conf: this file contains the configuration used by the above init files

As first step, copy the shell script, which is required by your Linux distribution into the /etc/init.dfolder. For example, if we were to install WildFly as a service on RHEL:

21