Monitoring the EJB container using the CLI

In this tutorial we will learn how to gather EJB 3 container statistics from JBoss AS 7 / JBoss EAP using the Command Line Interface.

 EJB Container statistics fall in two main categories:

  • Thread Pool statistics: including the core-threads and max-threads runtime statistics
  • EJB Deployment statistics: these are the metrics emitted by applications which include EJB

In any case, to collect statistics about the ejb3 subsystem you need to enable them first. You can do that from the CLI as follows:

/subsystem=ejb3:write-attribute(name=enable-statistics, value=true)

Let’s see in detail how to monitor each component of the EJB container.

Monitoring EJB Thread Pool statistics

A WildFly ejb thread pool consists of core threads and non-core threads. Since WildFly 18, non-core threads are created and used after core threads are saturated to service new requests.

To view default ejb thread pool configuration and its runtime metrics:

/subsystem=ejb3/thread-pool=default:read-resource(include-runtime, recursive=true)
    "outcome" => "success",
    "result" => {
        "active-count" => 0,
        "completed-task-count" => 240L,
        "core-threads" => undefined,
        "current-thread-count" => 5,
        "keepalive-time" => {
            "time" => 60L,
            "unit" => "SECONDS"
        "largest-thread-count" => 4,
        "max-threads" => 10,
        "name" => "default",
        "queue-size" => 0,
        "rejected-count" => 0,
        "task-count" => 616L,
        "thread-factory" => undefined

The active-count informs us about the the approximate number of threads that are actively executing tasks. The completed-task-count is the total number of tasks that have completed execution. The current-thread-count measures the current number of threads in the pool.

The largest-thread-count is the largest number of threads that have ever simultaneously been in the pool. The attribute queue-size measures the thread pool queue size. The task which haven’t been executed are measured in the rejected-count. Finally, task-count counts the approximate total number of tasks that have ever been scheduled for execution.

Monitor EJB Deployment statistics

You can monitor the statistics of applications using EJB through the CLI by inspecting the /deployment subsystem.ù

Example: the following query returns the EJB statistics for the Session Bean “HelloEJB” which is in the deployment unit “helloworld.jar”

    "outcome" => "success",
    "result" => {
        "component-class-name" => "HelloEJB",
        "declared-roles" => [],
        "execution-time" => 1L,
        "invocations" => 14L,
        "methods" => {"greet" => {
            "execution-time" => 1L,
            "invocations" => 4L,
            "wait-time" => 8L
        "peak-concurrent-invocations" => 1L,
        "pool-available-count" => 20,
        "pool-create-count" => 1,
        "pool-current-size" => 1,
        "pool-max-size" => 20,
        "pool-name" => "slsb-strict-max-pool",
        "pool-remove-count" => 0,
        "run-as-role" => undefined,
        "security-domain" => "other",
        "timers" => [],
        "wait-time" => 8L

You can also collect the statistics for all EJB deployment by using the star (*) expression:

/deployment=*/subsystem=ejb3:read-resource(include-runtime=true, recursive=true) 

On the other hand, if your EJB application is a subdeployment (helloworld.jar) of an EAR archive (helloworld.ear), you can traverse the deployment model as follows:

/deployment=helloWorld.ear/subdeployment=helloWorld.jar/subsystem=ejb3:read-resource(include-runtime=true, recursive=true)
Found the article helpful? if so please follow us on Socials