This chapter describes how to monitor Java EE web services in WebLogic Server 12.1.3 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:
Monitoring RESTful Web Services Using Enterprise Manager Fusion Middleware Control
Monitoring RESTful Web Services Using the Administration Console
To monitor your RESTful web services, you can use one of the methods defined in Table 8-1.
Table 8-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. |
In addition to the monitoring methods described in Table 8-1, Jersey 2.5.1 JAX-RS 2.0 Reference Implementation (RI) provides additional monitoring features, including support for event listeners and statistics monitoring. For more information, see "Monitoring Jersey Applications" in Jersey 2.5.1 User Guide.
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.
Using the WebLogic Server 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 WebLogic Server Administration Console, follow these steps:
Invoke the WebLogic Server 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
).
Follow the procedure described in "Monitor RESTful Web Services" in Oracle WebLogic Server Administration Console Online Help.
WebLogic Server provides several run-time MBeans, including those defined in Table 8-2, that capture run-time information and let you monitor run-time statistics for your RESTful web service applications.
Table 8-2 Run-time MBeans for Monitoring RESTful Web Services
Run-time MBean | Description |
---|---|
|
Displays monitoring information for the RESTful web service application. For more information, see "JaxRsApplicationRuntimeBean" in the WebLogic Server MBean Reference. |
|
Displays monitoring information about the RESTful web service application resource configuration. For more information, see "JaxRsResourceConfigTypeRuntimeBean" in the WebLogic Server MBean Reference. |
|
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. |
|
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
Invoke WLST, as described in "Invoking WLST" in Understanding the WebLogic Scripting Tool.
For example:
c:\Oracle\Middleware\wlserver\common\bin> wlst
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')
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>
Navigate to the Web application component runtime MBean.
For example, to navigate to runtime 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')
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')
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>
Navigate to any of the following run-time MBeans to view additional monitoring information. For more information about the MBeans, see Table 8-2 or the WebLogic Server MBean Reference.
ResourceConfig
RootResources
Servlet
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:\>
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 sections describe how to enable tracing based on whether you ar using Jersey 1.18 or 2.5.1 JAX-RS Reference Implementation (RI).
Using Jersey 1.18 (JAX-RS 1.1 RI), you can enable the tracing feature server-wide or on a per-request basis, as described in the following sections:
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 8-1 Example of a Trace Message
Trace 001: X-Jersey-Trace-001 match path "/items/3/tracks/2/" -> "/application\\.wadl(/.\*)?", "/happy(/.\*)?", "(/.\*)?"
You can enable server-wide tracing for RESTful web service applications that are packaged with servlets, as described in Packaging With a Servlet Using Jersey 1.18 (JAX-RS 1.1 RI), 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:
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.Trace</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
property. For more information, see FEATURE_TRACE
field description in the jersey-bundle 1.18 API Javadoc.
You can enable per-request tracing for RESTful web service applications that are packaged with servlets, as described in Packaging With a Servlet Using Jersey 1.18 (JAX-RS 1.1 RI), 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>
parameters, 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 FEATURE_TRACE_PER_REQUEST
field description in the jersey-bundle 1.18 API.
When enabled, the Jersey 2.5.1 tracing facility collects for individual requests useful information from all components of the JAX-RS server-side request processing pipeline. The information collected may provide vital details for troubleshooting your Jersey or JAX-RS application.
The tracing information for a single request is returned to the requesting client in the HTTP headers of the response. In addition, the information is logged on the server-side using a dedicated Java Logger instance.
For more information about enabling the Jersey 2.5.1 tracing facility, see "Tracing Support" in Jersey 2.5.1 User Guide.