7 Monitoring RESTful Web Services and Clients

This chapter describes how to monitor WebLogic Web services that conform to the Representational State Transfer (REST) architectural style using Java API for RESTful Web Services (JAX-RS).

This chapter includes the following sections:

About Monitoring RESTful Web Services

To monitor your RESTful Web services, you can use one of the methods defined in Table 7-1.

Table 7-1 Methods for Monitoring RESTful Web Services

Method Description

Fusion Middleware Control Enterprise Manager

Access run-time information and monitor run-time statistics, as described in Monitoring RESTful Web Services Using Enterprise Manager Fusion Middleware Control.

WebLogic Server Administration Console

Access run-time information and monitor run-time statistics, as described in Monitoring RESTful Web Services Using the Administration Console.

WebLogic Scripting Tool (WLST)

Access run-time information and monitor run-time statistics, as described in Monitoring RESTful Web Services Using WLST.

Logging filter

Monitor how a request is processed and dispatched to Jersey JAX-RS RI components, as described in Enabling the Tracing Feature.


Monitoring RESTful Web Services Using Enterprise Manager Fusion Middleware Control

Using Enterprise Manager Fusion Middleware Control, you can monitor statistics for your RESTful Applications and resources, such as error and invocation counts, execution times, and so on. For complete information, see "Monitoring Web Services" in Administering Web Services.

Monitoring RESTful Web Services Using the Administration Console

Using the Administration Console, you can monitor statistics for your RESTful Applications and resources, such as error and invocation counts, execution times, and so on.

To monitor your deployed RESTful Web services using the Administration Console, follow these steps:

  1. Invoke the Administration Console in your browser using the following URL:

    http://[host]:[port]/console
    

    where:

    • host refers to the computer on which WebLogic Server is running.

    • port refers to the port number on which WebLogic Server is listening (default value is 7001).

  2. Follow the procedure described in "Monitor RESTful Web services" in Oracle WebLogic Server Administration Console Online Help.

Monitoring RESTful Web Services Using WLST

WebLogic Server provides several run-time MBeans, including those defined in Table 7-2, that capture run-time information and let you monitor run-time statistics for your RESTful Web service applications.

Table 7-2 Run-time MBeans for Monitoring RESTful Web Services

Run-time MBean Description

JaxRsApplication

Displays monitoring information for the RESTful Web service application. For more information, see "JaxRsApplicationRuntimeBean" in the WebLogic Server MBean Reference.

ResourceConfig

Displays monitoring information about the RESTful Web service application resource configuration. For more information, see "JaxRsResourceConfigTypeRuntimeBean" in the WebLogic Server MBean Reference.

RootResources

Displays monitoring information about the RESTful Web service resource. Any object that is managed by a container (such as EJB) will have application scope. All other resources by default will have request scope. For more information, see "JaxRsResourceRuntimeBean" in the WebLogic Server MBean Reference.

Servlet

Displays monitoring information for the servlet that hosts the RESTful Web service application. For more information, see "ServletRuntimeMBean" in the WebLogic Server MBean Reference.


To monitor RESTful Web services using WLST, perform the steps provided in the following procedure.

In this procedure, the example steps provided demonstrate how to monitor the RESTful Web Services sample delivered with the WebLogic Server Samples Server, described at "Sample Application and Code Examples" in Understanding Oracle WebLogic Server

  1. Invoke WLST, as described in "Invoking WLST" in Understanding the WebLogic Scripting Tool.

    For example:

    c:\> java weblogic.WLST
    
  2. Connect to the Administration Server instance, as described in "connect" in WLST Command Reference for WebLogic Server.

    For example:

    wls:/offline> connect('weblogic','password','t3://localhost:8001') 
    
  3. Navigate to the server run-time MBean, as described in "serverRuntime" in WLST Command Reference for WebLogic Server.

    For example:

    wls:/wl_server/serverConfig> serverRuntime()
    Location changed to serverRuntime tree. This is a read-only tree
    with ServerRuntimeMBean as the root.
    For more help, use help('serverRuntime')
    wls:/wl_server/serverRuntime> 
    
  4. Navigate to the Web application component run-time MBean.

    For example, to navigate to run-time MBean for the application named jaxrs:

    wls:/wl_server/serverRuntime> cd('ApplicationRuntimes/jaxrs')
    wls:/wl_server/serverRuntime/ApplicationRuntimes/jaxrs> cd('ComponentRuntimes')
    wls:/wl_server/serverRuntime/ApplicationRuntimes/jaxrs/ComponentRuntimes> cd('examplesServer_/jaxrs')
    
  5. Navigate to the application run-time MBean for the RESTful Web service servlet.

    For example:

    wls:/wl_server/serverRuntime/ApplicationRuntimes/jaxrs/ComponentRuntimes/examplesServer_/jaxrs> cd('JaxRsApplications/RestServlet')
    
  6. Review the monitoring information displayed for the RESTful Web service application. For more information, see "JaxRsApplicationRuntimeBean" in the WebLogic Server MBean Reference.

    For example:

    wls:/wl_server/serverRuntime/ApplicationRuntimes/jaxrs/ComponentRuntimes/example
    sServer_/jaxrs/JaxRsApplications/RestServlet> ls()
    dr--   ResourceConfig
    dr--   RootResources
    dr--   Servlet
     
    -r--   ErrorCount                                   0
    -r--   ExecutionTimeAverage                         0
    -r--   ExecutionTimeHigh                            0
    -r--   ExecutionTimeLow                             0
    -r--   ExecutionTimeTotal                           0
    -r--   HttpMethodCounts                             {}
    -r--   InvocationCount                              0
    -r--   LastErrorDetails                             null
    -r--   LastErrorMapper                              null
    -r--   LastErrorTime                                0
    -r--   LastHttpMethod                               null
    -r--   LastInvocationTime                           0
    -r--   LastResponseCode                             -1
    -r--   Name                                         RestServlet
    -r--   ResponseCodeCounts                           {}
    -r--   StartTime                                    1321907929703
    -r--   Type                                         JaxRsApplicationRuntime
     
    -r-x   preDeregister                                Void :
    
    wls:/wl_server/serverRuntime/ApplicationRuntimes/jaxrs/ComponentRuntimes/example
    sServer_/jaxrs/JaxRsApplications/RestServlet>
    
  7. Navigate to any of the following run-time MBeans to view additional monitoring information. For more information about the MBeans, see Table 7-2 or the WebLogic Server MBean Reference.

    • ResourceConfig

    • RootResources

    • Servlet

  8. Exit WLST, as described in "Exiting WLST" in Understanding the WebLogic Scripting Tool.

    For example:

    wls:/wl_server/serverRuntime/ApplicationRuntimes/jaxrs/ComponentRuntimes/example
    sServer_/jaxrs/JaxRsApplications/RestServlet> exit()
    Exiting WebLogic Scripting Tool ...
    c:\>
    

Enabling the Tracing Feature

The Jersey tracing feature provides useful information that describes how a request is processed and dispatched to Jersey JAX-RS RI components. Trace messages are output in the same order as they occur, so the numbering is useful to reconstruct the tracing order.

The following provides an example of a trace message. The message shows the request path and the initial set of regular expressions that will be matched, in order from left to right.

Example 7-1 Example of a Trace Message

Trace 001:
X-Jersey-Trace-001  match path "/items/3/tracks/2/" -> "/application\\.wadl(/.\*)?", "/happy(/.\*)?", "(/.\*)?"

You can enable this feature server-wide or on a per-request basis, as described in the following sections:

How to Enable Server-wide Tracing

You can enable server-wide tracing for RESTful Web service applications that are packaged with servlets, as described in Packaging With a Servlet, and the following elements are present in the web.xml file:

  • Servlet class, defined as follows:

    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
    
  • One of the following <init-param>s, set to True:

    • com.sun.jersey.config.feature.TracePerRequest

    • com.sun.jersey.config.feature.Trace

To enable server-wide tracing:

How to Enable Per-request Tracing

You can enable per-request tracing for RESTful Web service applications that are packaged with servlets, as described in Packaging With a Servlet, and the following elements are present in the web.xml file:

  • Servlet class, defined as follows:

    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
    
  • One of the following <init-param>s, set to True:

    • com.sun.jersey.config.feature.TracePerRequest

    • com.sun.jersey.config.feature.Trace

With per-request tracing, trace messages are output if a request header is present with the header name of X-Jersey-Trace-Accept.

Trace messages are output primarily as response headers with a header name of the form X-Jersey-Trace-XXX, where XXX is a decimal value corresponding to the trace message number, and a header value that is the trace message. In certain cases, trace messages will be logged to the server if they cannot be included in the response headers, for example if the messages are too long.

To enable tracing on a per-request basis:

  • Update the web.xml deployment descriptor that is packaged with your application to add the following <init-param> element:

    <init-param>
        <param-name>com.sun.jersey.config.feature.TracePerRequest</param-name>
        <param-value>true</param-value>
    </init-param>
    

    For more information about the <init-param> element, see "servlet" in Developing Web Applications, Servlets, and JSPs for Oracle WebLogic Server.

  • Enable the com.sun.jersey.api.core.ResourceConfig.FEATURE_TRACE_PER_REQUEST property. For more information, see https://jersey.java.net/apidocs/1.13/jersey/index.html?com/sun/jersey/api/core/ResourceConfig.html#FEATURE_TRACE.