Configure JBoss EAP to enable application database access to a MariaDB database.
| Resources | |
|---|---|
| Files |
/opt/domain
|
| Application URL |
http://172.25.250.10:8080/kitchensink
http://172.25.250.11:8080/kitchensink
|
| Resources |
|
Outcomes
You should be able to install a MariaDB JDBC driver as a module, and create a data source in a managed domain.
Use the following command to prepare the environment:
[student@workstation ~]$ lab start datasources-review
A JBoss EAP administrator has set up a managed domain with two host controllers running on servera and serverb machines.
The domain controller runs on the workstation machine.
The domain and host configuration files are stored in the /opt/domain directory on all three machines.
![]() |
In this exercise you deploy a version of the kitchensink.war application which does not have a defined datasource.
To use the kitchensink.war application, first you must define a datasource for the MariaDB instance that this exercise deploys.
Instructions
Add the MariaDB module to each host.
The kitchensink application uses a MariaDB database. In a managed domain, each host needs to add the module for the MariaDB JDBC driver individually.
There is a copy of the driver on every host at /home/jboss/mariadb-java-client-3.2.0.jar.
The driver is owned by the jboss user.
Use the management CLI in disconnected mode to create a module called com.mariadb on the workstation machine.
The MariaDB JDBC driver has the following dependencies:
javax.api
sun.jdk
ibm.jdk
javax.transaction.api
[student@workstation ~]$ sudo -u jboss /opt/jboss-eap-7.4/bin/jboss-cli.sh \
--command="module add --name=com.mariadb \
--resources=/home/jboss/mariadb-java-client-3.2.0.jar \
--dependencies=javaee.api,sun.jdk,ibm.jdk,javax.api,javax.transaction.api"Repeat the command on servera to create a module for the MariaDB JDBC driver.
[student@workstation ~]$ ssh jboss@servera \
'/opt/jboss-eap-7.4/bin/jboss-cli.sh \
--command="module add --name=com.mariadb \
--resources=/home/jboss/mariadb-java-client-3.2.0.jar \
--dependencies=javaee.api,sun.jdk,ibm.jdk,javax.api,javax.transaction.api"'Note that you must use single quotes to quote the complete command you are sending to servera over ssh.
Repeat the command on serverb to create a module for the MariaDB JDBC driver.
[student@workstation ~]$ ssh jboss@serverb \
'/opt/jboss-eap-7.4/bin/jboss-cli.sh \
--command="module add --name=com.mariadb \
--resources=/home/jboss/mariadb-java-client-3.2.0.jar \
--dependencies=javaee.api,sun.jdk,ibm.jdk,javax.api,javax.transaction.api"'Validate that the driver is installed correctly as a module on workstation, servera, and serverb.
Use the following command from a terminal window:
[student@workstation ~]$ls /opt/jboss-eap-7.4/modules/com/mariadb/mainmariadb-java-client-3.2.0.jar module.xml [student@workstation ~]$ssh jboss@servera \ ls /opt/jboss-eap-7.4/modules/com/mariadb/mainmariadb-java-client-3.2.0.jar module.xml [student@workstation ~]$ssh jboss@serverb \ ls /opt/jboss-eap-7.4/modules/com/mariadb/mainmariadb-java-client-3.2.0.jar module.xml
Start the domain controller.
Use /opt/domain as the jboss.domain.base.dir value.
The host file for the domain controller is called host-master.xml.
Note that the jboss user owns the /opt/domain directory.
Therefore, you must start the domain controller by using the jboss user.
Start the host controllers on the servera and the serverb machines.
Use /opt/domain as the jboss.domain.base.dir value.
The host file for the host controllers is host-slave.xml.
Note that the jboss user owns the /opt/domain directory.
Therefore, you must start the host controller by using the jboss user.
You can safely ignore the following output:
WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.wildfly.extension.elytron.SSLDefinitions (jar:file:/opt/jboss-eap-7.4/modules/system/layers/base/.overlays/layer-base-jboss-eap-7.4.11.CP/org/wildfly/extension/elytron/main/wildfly-elytron-integration-15.0.26.Final-redhat-00001.jar!/) to method com.sun.net.ssl.internal.ssl.Provider.isFIPS() WARNING: Please consider reporting this to the maintainers of org.wildfly.extension.elytron.SSLDefinitions WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release
For more information, refer to https://access.redhat.com/solutions/4996491.
Start the host controller on the servera machine.
Open a new terminal window on the workstation machine and run the following command:
[student@workstation ~]$ssh -t jboss@servera /opt/jboss-eap-7.4/bin/domain.sh \-Djboss.domain.base.dir=/opt/domain/ \-Djboss.domain.master.address=172.25.250.9 \--host-config=host-slave.xml
Note the use of the -t option for the ssh command to allocate a pseudo-terminal.
You must use this option to properly propagate the signals that Ctrl+C sends to the remote machine.
Start the host controller on the serverb machine.
Open a new terminal window on the workstation machine and run the following command:
[student@workstation ~]$ssh -t jboss@serverb /opt/jboss-eap-7.4/bin/domain.sh \-Djboss.domain.base.dir=/opt/domain/ \-Djboss.domain.master.address=172.25.250.9 \--host-config=host-slave.xml
Note the use of the -t option for the ssh command to allocate a pseudo-terminal.
You must use this option to properly propagate the signals that Ctrl+C sends to the remote machine.
Verify that both host controllers connect to the domain controller and form a managed domain.
Inspect the console window where you started the domain controller and verify that both servera and serverb are registered as secondary controllers.
[Host Controller] 03:28:53,434 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: JBoss EAP 7.4.11.GA (WildFly Core 15.0.26.Final-redhat-00001) (Host Controller) started in 3622ms - Started 80 of 81 services (22 services are lazy, passive or on-demand) [Host Controller] 03:29:12,302 INFO [org.jboss.as.domain.controller] (Host Controller Service Threads - 37)WFLYHC0019: Registered remote slave host "servera", JBoss JBoss EAP 7.4.11.GA (WildFly 15.0.26.Final-redhat-00001) [Host Controller] 03:29:47,951 INFO [org.jboss.as.domain.controller] (Host Controller Service Threads - 37)WFLYHC0019: Registered remote slave host "serverb", JBoss JBoss EAP 7.4.11.GA (WildFly 15.0.26.Final-redhat-00001)
Define the MariaDB driver for the full profile.
In a new terminal window on the workstation machine, start the management CLI and connect to the domain controller as the jboss user.
Register a JDBC driver called mariadb for the full profile.
[domain@172.25.250.9:9990 /] /profile=full/subsystem=datasources\
/jdbc-driver=mariadb:add(driver-name=mariadb,driver-module-name=com.mariadb)
{
"outcome" => "success",
"result" => undefined,
"server-groups" => {
"Group1" => {"host" => {
"servera" => {"servera.1" => {"response" => {
"outcome" => "success",
"result" => undefined
}}},
"serverb" => {"serverb.1" => {"response" => {
"outcome" => "success",
"result" => undefined
}}}
}},
"Group2" => {"host" => {
"servera" => {"servera.2" => {"response" => {
"outcome" => "success",
"result" => undefined
}}},
"serverb" => {"serverb.2" => {"response" => {
"outcome" => "success",
"result" => undefined
}}}
}}
}
}Create the kitchensink MariaDB data source.
Using the management CLI on the workstation, create the kitchensink MariaDB data source for the full profile with the following properties:
| Field | Value |
|---|---|
Name
|
kitchensink
|
JNDI Name
|
java:jboss/datasources/KitchensinkQuickstartDS
|
Driver Name
|
mariadb
|
Connection URL
|
jdbc:mariadb://172.25.250.9:3306/lab_db
|
Username
|
developer
|
Password
|
redhat123
|
Deploy the kitchensink.war application.
This version of the kitchensink application requires defining a datasource with the java:jboss/datasources/KitchensinkQuickstartDS JNDI name.
Use the management CLI to deploy the /tmp/kitchensink.war file to the Group1 server group.
Verify that the kitchensink application uses the MariaDB data source.
After the application is deployed to the Group1 server group, visit the application on each of the servers in the server group.
Create a member by using the form in one of the servers, and verify that it shows in the other server.
Navigate to http://172.25.250.10:8080/kitchensink and create a member by filling out the form with the following data:
| Field | Value |
|---|---|
Name
|
user_one
|
Email
|
user_one@example.com
|
Phone
|
1234567890
|
Click and verify that the user_one member shows in the table below the form.
Navigate to http://172.25.250.11:8080/kitchensink and verify that the user_one member shows in the table.
Clean up. Press Ctrl+C to stop the management CLI and the domain and host controllers.