Exercise - Access the JBoss EAP administration tools and application logs
In this exercise, you access the JBoss administration tools and stream the application logs.
Set up environment variables
For this exercise, you need some environment variables from prior exercises. If you're using the same Bash window, these variables should still exist. If the variables are no longer available, use the following commands to recreate them. Be sure to replace the <...> placeholders with your own values, and use the same values that you used previously.
export RESOURCE_GROUP_NAME=<resource-group>
export WEB_APP_NAME=<app-name>
Create a TCP tunnel
To access the remote server, create a TCP tunnel between your remote server and your local machine by using the following command:
az webapp create-remote-connection \
--resource-group ${RESOURCE_GROUP_NAME} \
--name ${WEB_APP_NAME}
The output contains the TCP tunnel port number, username, and password. Be sure to save aside this information for later use.
Sign in by using SSH and the TCP tunnel
To sign in to the server using SSH and a TCP tunnel, use the following steps:
Open a new command terminal.
Sign in to the server by using the following commands. Be sure to replace the
<port-number>
placeholder with the port number you retrieved in the previous section.export PORT_NUMBER=<port-number> ssh root@127.0.0.1 -L 9990:localhost:9990 -p $PORT_NUMBER
Tip
If you want to access to the JBoss EAP admin web console, specify the
-L 9990:localhost:9990
option. Then, access the JBoss web console athttp://localhost:9990/console
. If you don't need to sign in to the JBoss web console, you can remove the-L
option.The following output is typical:
ssh root@127.0.0.1 -L 9990:localhost:9990 -p 65171 root@127.0.0.1's password: Last login: Tue Feb 25 07:44:49 2025 from 169.254.129.2 _|_| _| _| _|_|_|_| _| _| _| _|_| _|_| _|_|_|_| _| _| _| _|_| _|_|_|_| _| _| _| _| _| _| _| _| _| _|_|_|_| _|_|_| _| _|_|_| J A V A O N A P P S E R V I C E Documentation: https://aka.ms/appservice **NOTE**: No files or system changes outside of /home will persist beyond your application's current session. /home is your application's persistent storage and is shared across all the server instances.
Run the JBoss CLI tool
After you sign in to the remote server, you can run the JBoss EAP admin CLI tool, /opt/eap/bin/jboss-cli.sh, by using the following steps:
Connect to JBoss EAP by using the following command:
/opt/eap/bin/jboss-cli.sh --connect
The following output is typical:
OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
After you connect to the JBoss EAP Server, use the following command at the JBoss prompt to get the JBoss server information:
product-info
The following output is typical:
{ "outcome" => "success", "result" => [{"summary" => { "host-name" => "jakartaee-aaaabbbb", "instance-identifier" => "aaaaaaaa-1111-bbbb-2222-cccccccccccc", "product-name" => "JBoss EAP", "product-version" => "8.0 Update 4.1", "product-community-identifier" => "Product", "product-home" => "/opt/eap", "standalone-or-domain-identifier" => "STANDALONE_SERVER", "host-operating-system" => "Ubuntu 22.04.5 LTS", "host-cpu" => { "host-cpu-arch" => "amd64", "host-core-count" => 2 }, "jvm" => { "name" => "OpenJDK 64-Bit Server VM", "java-version" => "17", "jvm-version" => "17.0.13", "jvm-vendor" => "Microsoft", "java-home" => "/usr/lib/jvm/msopenjdk-17-amd64" } }}] }
Use the following command to list all of the deployed applications:
ls deployment
The following output is typical:
ROOT.war
Test the database connection by using the following command:
/subsystem=datasources/data-source="JPAWorldDataSourceDS":test-connection-in-pool
The following output is typical:
{ "outcome" => "success", "result" => [true] }
Exit from the JBoss EAP CLI by using the following command:
exit
Access the JBoss EAP admin web console
Next, access the JBoss admin web console by using the following steps:
Create an admin user and password for authentication by using the following command:
/opt/eap/bin/add-user.sh -u admin -p admin -r ManagementRealm
The following output is typical:
Picked up JAVA_TOOL_OPTIONS: -Xmx5480M -Djava.net.preferIPv4Stack=true Updated user 'admin' to file '/opt/eap/standalone/configuration/mgmt-users.properties' Updated user 'admin' to file '/opt/eap/domain/configuration/mgmt-users.properties'
Access the web console from a web browser in your local environment by using
http://127.0.0.1:9990/console
.In the authentication dialog box, sign in with the previously created username and password.
After you sign in to the web console, the following screen appears:
Confirm that you created the datasource by selecting Configuration > Subsystems > Datasources & Drivers > Datasources.
You can also confirm the RESTful endpoints of your application by selecting Runtime > <your-system> > JAX-RS > <your-application>.
Warning
If you directly access the remote server via the JBoss CLI command or web console and add or update a configuration, the configuration is cleared and deleted after the Azure App Service instance is restarted. To persist the configuration, use a startup script such as the createMySQLDataSource.sh script used in a previous unit.
Open a log stream
Access the logs by using the following command:
az webapp log tail \
--resource-group ${RESOURCE_GROUP_NAME} \
--name ${WEB_APP_NAME}
The following output is typical:
2025-02-25T06:58:11.5107300Z Waiting for main process to exit. GLOBAL_PID_MAIN=123
2025-02-25T06:58:11.5109525Z Waiting for GLOBAL_PID_MAIN == 123
2025-02-25T06:58:12.7891598Z 2025-02-25 06:58:12,786 WARN [org.apache.activemq.artemis.core.server.impl.FileLockNodeManager] (Thread-2 (ActiveMQ-scheduled-threads)) Lost the lock according to the monitor, notifying listeners
2025-02-25T06:58:14.3783443Z 2025-02-25 06:58:14,377 INFO [org.jboss.as.jpa] (MSC service thread 1-2) WFLYJPA0002: Read persistence.xml for JPAWorldDatasourcePU
2025-02-25T06:58:14.7548991Z 2025-02-25 06:58:14,752 INFO [org.jipijapa] (MSC service thread 1-3) JIPIORMV6020260: Second level cache enabled for ROOT.war#JPAWorldDatasourcePU
2025-02-25T06:58:14.7971763Z 2025-02-25 06:58:14,796 WARN [org.apache.activemq.artemis.core.server.impl.FileLockNodeManager] (Thread-2 (ActiveMQ-scheduled-threads)) Lost the lock according to the monitor, notifying listeners
2025-02-25T06:58:14.9371057Z 2025-02-25 06:58:14,924 INFO [org.jboss.weld.deployer] (MSC service thread 1-4) WFLYWELD0003: Processing weld deployment ROOT.war
2025-02-25T06:58:15.2875956Z 2025-02-25 06:58:15,280 INFO [org.hibernate.validator.internal.util.Version] (MSC service thread 1-4) HV000001: Hibernate Validator 8.0.1.Final-redhat-00001
2025-02-25T06:58:16.0075988Z 2025-02-25 06:58:16,003 INFO [org.infinispan.CONTAINER] (ServerService Thread Pool -- 78) ISPN000556: Starting user marshaller 'org.wildfly.clustering.infinispan.marshalling.jboss.JBossMarshaller'
2025-02-25T06:58:16.0534913Z 2025-02-25 06:58:16,048 INFO [org.jipijapa] (MSC service thread 1-1) JIPIORMV6020260: Second level cache enabled for ROOT.war#JPAWorldDatasourcePU
2025-02-25T06:58:16.1970192Z 2025-02-25 06:58:16,192 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-1) WFLYJCA0005: Deploying non-JDBC-compliant driver class com.mysql.cj.jdbc.Driver (version 9.2)
2025-02-25T06:58:16.2695781Z 2025-02-25 06:58:16,265 INFO [org.jboss.weld.Version] (MSC service thread 1-1) WELD-000900: 5.1.2 (redhat)
2025-02-25T06:58:16.4228682Z 2025-02-25 06:58:16,421 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-3) WFLYJCA0018: Started Driver service with driver-name = ROOT.war_com.mysql.cj.jdbc.Driver_9_2
2025-02-25T06:58:16.4261069Z 2025-02-25 06:58:16,425 INFO [org.jboss.as.connector.subsystems.datasources.AbstractDataSourceService$AS7DataSourceDeployer] (MSC service thread 1-3) IJ020018: Enabling <validate-on-match> for java:jboss/datasources/JPAWorldDataSource
2025-02-25T06:58:16.4349571Z 2025-02-25 06:58:16,428 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) WFLYJCA0001: Bound data source [java:jboss/datasources/JPAWorldDataSource]
2025-02-25T06:58:16.7892296Z 2025-02-25 06:58:16,787 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 78) WFLYJPA0010: Starting Persistence Unit (phase 1 of 2) Service 'ROOT.war#JPAWorldDatasourcePU'
2025-02-25T06:58:16.8070373Z 2025-02-25 06:58:16,805 INFO [org.hibernate.jpa.internal.util.LogHelper] (ServerService Thread Pool -- 78) HHH000204: Processing PersistenceUnitInfo [name: JPAWorldDatasourcePU]
Exercise summary
In this unit, you learned how to configure and deploy a Jakarta EE 10 application to JBoss EAP on Azure App Service. Then, you used a DataSource
object for connecting MySQL to JBoss EAP in a startup script.
You also learned how to access the remote server from both the CLI and the graphical user interface (GUI) by using a TCP tunnel. Finally, you accessed the log file from a local machine.