| 1 |
<?xml version="1.0" encoding="utf-8"?> |
| 2 |
<!-- |
| 3 |
~ Copyright 2009-2013 Roland Huss |
| 4 |
~ |
| 5 |
~ Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 |
~ you may not use this file except in compliance with the License. |
| 7 |
~ You may obtain a copy of the License at |
| 8 |
~ |
| 9 |
~ http://www.apache.org/licenses/LICENSE-2.0 |
| 10 |
~ |
| 11 |
~ Unless required by applicable law or agreed to in writing, software |
| 12 |
~ distributed under the License is distributed on an "AS IS" BASIS, |
| 13 |
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 |
~ See the License for the specific language governing permissions and |
| 15 |
~ limitations under the License. |
| 16 |
--> |
| 17 |
|
| 18 |
<section id="agents-war"> |
| 19 |
<title>Java EE Agent (WAR)</title> |
| 20 |
|
| 21 |
<section id="war-agent-installation"> |
| 22 |
<title>Installation and Configuration</title> |
| 23 |
<para> |
| 24 |
The WAR agent is the most popular variant, and can be deployed |
| 25 |
in a servlet container just like any other Java EE web application.<sidebar> |
| 26 |
<title>Tomcat example</title> |
| 27 |
A simple example for deploying the agent on Tomcat can be found |
| 28 |
in the Jolokia <ulink |
| 29 |
url="http://www.jolokia.org/tutorial.html">quickstart</ulink>. |
| 30 |
</sidebar> |
| 31 |
Often, installation is simply a matter of copying the agent WAR to |
| 32 |
a deployment directory. On other platforms an administrative Web |
| 33 |
GUI or a command line tool need to be used for |
| 34 |
deployment. Providing detailed installation instructions for every servlet |
| 35 |
container is out of scope for this document. |
| 36 |
</para> |
| 37 |
<para> |
| 38 |
The servlet itself can be configured in two ways: |
| 39 |
</para> |
| 40 |
<variablelist> |
| 41 |
<varlistentry> |
| 42 |
<term><emphasis role="bold">Servlet Init Parameters</emphasis></term> |
| 43 |
<listitem> |
| 44 |
Jolokia can be configured with <literal>init-param</literal> |
| 45 |
declarations within the servlet definition in |
| 46 |
<filename>WEB-INF/web.xml</filename>. The known parameters are |
| 47 |
described in <xref linkend="agent-war-init-params"/>. The |
| 48 |
stock agent needs to be repackaged, though, in order to modify |
| 49 |
the internal <filename>web.xml</filename>. |
| 50 |
</listitem> |
| 51 |
</varlistentry> |
| 52 |
<varlistentry> |
| 53 |
<term><emphasis role="bold">Servlet Context Parameters</emphasis></term> |
| 54 |
<listitem> |
| 55 |
A more convenient possibility might be to use servlet context |
| 56 |
parameters, which can be configured outside the WAR |
| 57 |
archive. This is done differently for each servlet container |
| 58 |
but involves typically the editing of a configuration |
| 59 |
file. E.g. for <ulink |
| 60 |
url="http://tomcat.apache.org/tomcat-7.0-doc/config/context.html">Tomcat</ulink>, |
| 61 |
the context for |
| 62 |
the Jolokia agent can be adapted by putting a file |
| 63 |
<filename>jolokia.xml</filename> below |
| 64 |
<filename>$TC/conf/Catalina/localhost/</filename> with a |
| 65 |
content like: <programlisting><![CDATA[<Context> |
| 66 |
<Parameter name="maxDepth" value="1"/> |
| 67 |
</Context>]]></programlisting> |
| 68 |
</listitem> |
| 69 |
</varlistentry> |
| 70 |
</variablelist> |
| 71 |
<para> |
| 72 |
The configuration options <literal>discoveryEnabled</literal> and |
| 73 |
<literal>discoveryAgentUrl</literal> can be provided via environment |
| 74 |
variables or system properties, too. See the below for details. |
| 75 |
</para> |
| 76 |
<table id="agent-war-init-params"> |
| 77 |
<title>Servlet init parameters</title> |
| 78 |
<thead> |
| 79 |
<tr> |
| 80 |
<td>Parameter</td> |
| 81 |
<td>Description</td> |
| 82 |
<td>Example</td> |
| 83 |
</tr> |
| 84 |
</thead> |
| 85 |
<tr> |
| 86 |
<td><constant>dispatcherClasses</constant></td> |
| 87 |
<td> |
| 88 |
Classnames (comma separated) of <constant>RequestDispatcher</constant> used in addition |
| 89 |
to the |
| 90 |
<constant>LocalRequestDispatcher</constant>. Dispatchers are |
| 91 |
a technique used by the JSR-160 proxy to dispatch (or |
| 92 |
'route') a request to a different destination. By default no extract dispatchers are enabled (changed in 1.5.0) |
| 93 |
You can use the system property <literal>org.jolokia.jsr160ProxyEnabled</literal> or the |
| 94 |
environment variable <literal>JOLOKIA_JSR160_PROXY_ENABLED</literal> to enable the the JSR-160 proxy. |
| 95 |
In that case you should be sure that you enable authentication for the web application to protect access |
| 96 |
to the proxy. |
| 97 |
</td> |
| 98 |
<td> |
| 99 |
<literal>org.jolokia.jsr160.Jsr160RequestDispatcher</literal> |
| 100 |
(this is the dispatcher for the JSR-160 proxy) |
| 101 |
</td> |
| 102 |
</tr> |
| 103 |
<tr> |
| 104 |
<td><constant>jsr160ProxyAllowedTargets</constant></td> |
| 105 |
<td> |
| 106 |
Path to a white list of patterns which are matched against possible |
| 107 |
JMX service URL for incoming requests |
| 108 |
</td> |
| 109 |
<td> |
| 110 |
<literal>/opt/jolokia/jsr160-proxy-allowed-patterns.txt</literal> |
| 111 |
</td> |
| 112 |
</tr> |
| 113 |
<tr> |
| 114 |
<td><constant>policyLocation</constant></td> |
| 115 |
<td> |
| 116 |
Location of the policy file to use. This is either a URL |
| 117 |
which can read from (like a <literal>file:</literal> or |
| 118 |
<literal>http:</literal> URL) or with the special protocol |
| 119 |
<literal>classpath:</literal> which is used for looking up |
| 120 |
the policy file in the web application's classpath. See |
| 121 |
<xref linkend="security-policy-location"/> for details about this |
| 122 |
parameter. |
| 123 |
</td> |
| 124 |
<td> |
| 125 |
<filename>file:///home/jolokia/jolokia-access.xml</filename> |
| 126 |
for a file based access to the policy file. Default is |
| 127 |
<filename>classpath:/jolokia-access.xml</filename> |
| 128 |
</td> |
| 129 |
</tr> |
| 130 |
<tr> |
| 131 |
<td><constant>restrictorClass</constant></td> |
| 132 |
<td> |
| 133 |
Full classname of an implementation of <literal>org.jolokia.restrictor.Restrictor</literal> |
| 134 |
which is used as a custom restrictor for securing access via Jolokia. |
| 135 |
</td> |
| 136 |
<td> |
| 137 |
<literal>com.mycompany.jolokia.CustomRestrictor</literal> (which must be included in the |
| 138 |
war file and must implement <literal>org.jolokia.restrictor.Restrictor</literal>) |
| 139 |
</td> |
| 140 |
</tr> |
| 141 |
<tr> |
| 142 |
<td><constant>allowDnsReverseLookup</constant></td> |
| 143 |
<td> |
| 144 |
Access can be restricted based on the remote host accessing Jolokia. This host can be |
| 145 |
specified as address or an hostname. However, using the hostname normally requires a reverse |
| 146 |
DNS lookup which might slow down operations. In order to avoid this reverse DNS lookup |
| 147 |
set this property to <literal>false</literal>. |
| 148 |
</td> |
| 149 |
<td> |
| 150 |
Default: <constant>true</constant> |
| 151 |
</td> |
| 152 |
</tr> |
| 153 |
<tr> |
| 154 |
<td><constant>debug</constant></td> |
| 155 |
<td> |
| 156 |
Debugging state after startup. Can be changed via |
| 157 |
the config MBean during runtime. |
| 158 |
</td> |
| 159 |
<td> |
| 160 |
Default: <constant>false</constant> |
| 161 |
</td> |
| 162 |
</tr> |
| 163 |
<tr> |
| 164 |
<td><constant>logHandlerClass</constant></td> |
| 165 |
<td> |
| 166 |
Loghandler to use for providing logging output. By default |
| 167 |
logging is written to standard out and error but you can provide |
| 168 |
here a Java class implementing <literal>org.jolokia.util.LogHandler</literal> |
| 169 |
for an alternative log output. Two alternative implementations are included in |
| 170 |
this agent: |
| 171 |
<itemizedlist> |
| 172 |
<listitem> |
| 173 |
<para> |
| 174 |
<classname>org.jolokia.util.QuietLogHandler</classname> which switches off |
| 175 |
logging completely. |
| 176 |
</para> |
| 177 |
</listitem> |
| 178 |
<listitem> |
| 179 |
<para> |
| 180 |
<classname>org.jolokia.util.JulLogHandler</classname> which uses a <literal>java.util.logging</literal> Logger with name <literal>org.jolokia</literal> |
| 181 |
</para> |
| 182 |
</listitem> |
| 183 |
</itemizedlist> |
| 184 |
</td> |
| 185 |
<td> |
| 186 |
Example: <constant>org.jolokia.util.LogHandler.Quiet</constant> |
| 187 |
</td> |
| 188 |
</tr> |
| 189 |
<tr> |
| 190 |
<td><constant>historyMaxEntries</constant></td> |
| 191 |
<td> |
| 192 |
Entries to keep in the history. Can be changed at |
| 193 |
runtime via the config MBean. |
| 194 |
</td> |
| 195 |
<td> |
| 196 |
Default: <constant>10</constant> |
| 197 |
</td> |
| 198 |
</tr> |
| 199 |
<tr> |
| 200 |
<td><constant>debugMaxEntries</constant></td> |
| 201 |
<td> |
| 202 |
Maximum number of entries to keep in the local |
| 203 |
debug history (if enabled). Can be changed via |
| 204 |
the config MBean at runtime. |
| 205 |
</td> |
| 206 |
<td> |
| 207 |
Default: <constant>100</constant> |
| 208 |
</td> |
| 209 |
</tr> |
| 210 |
<tr> |
| 211 |
<td><constant>maxDepth</constant></td> |
| 212 |
<td> |
| 213 |
Maximum depth when traversing bean properties. |
| 214 |
If set to 0, depth checking is disabled |
| 215 |
</td> |
| 216 |
<td> |
| 217 |
Default: <constant>15</constant> |
| 218 |
</td> |
| 219 |
</tr> |
| 220 |
<tr> |
| 221 |
<td><constant>maxCollectionSize</constant></td> |
| 222 |
<td> |
| 223 |
Maximum size of collections returned when |
| 224 |
serializing to JSON. When set to 0, |
| 225 |
collections are never truncated. |
| 226 |
</td> |
| 227 |
<td> |
| 228 |
Default: <constant>1000</constant> |
| 229 |
</td> |
| 230 |
</tr> |
| 231 |
<tr> |
| 232 |
<td><constant>maxObjects</constant></td> |
| 233 |
<td> |
| 234 |
Maximum number of objects which are traversed |
| 235 |
when serializing a single response. Use this |
| 236 |
as an airbag to avoid boosting your memory and |
| 237 |
network traffic. Nevertheless, when set to 0 |
| 238 |
no limit is imposed. |
| 239 |
</td> |
| 240 |
<td> |
| 241 |
Default: <constant>0</constant> |
| 242 |
</td> |
| 243 |
</tr> |
| 244 |
<tr> |
| 245 |
<td><constant>mbeanQualifier</constant></td> |
| 246 |
<td> |
| 247 |
Qualifier to add to the ObjectName of Jolokia's own |
| 248 |
MBeans. This can become necessary if more than one agent is |
| 249 |
active within a servlet container. This qualifier is added |
| 250 |
to the <constant>ObjectName</constant> of this agent with a |
| 251 |
comma. For example a <constant>mbeanQualifier</constant> |
| 252 |
with the value <constant>qualifier=own</constant> will |
| 253 |
result in Jolokia server handler MBean with the name |
| 254 |
<constant>jolokia:type=ServerHandler,qualifier=own</constant> |
| 255 |
</td> |
| 256 |
<td></td> |
| 257 |
</tr> |
| 258 |
<tr> |
| 259 |
<td><constant>mimeType</constant></td> |
| 260 |
<td> |
| 261 |
MIME to use for the JSON responses. Only <constant>application/json</constant> and |
| 262 |
<constant>text/plain</constant> are allowed. |
| 263 |
If any other type is given, Jolokia falls back to <constant>text/plain</constant>. |
| 264 |
</td> |
| 265 |
<td> |
| 266 |
Default: <constant>text/plain</constant> |
| 267 |
</td> |
| 268 |
</tr> |
| 269 |
<tr> |
| 270 |
<td><constant>canonicalNaming</constant></td> |
| 271 |
<td> |
| 272 |
This option specifies in which order the key-value |
| 273 |
properties within ObjectNames as returned by |
| 274 |
<constant>list</constant> or <constant>search</constant> are |
| 275 |
returned. By default this is the so called 'canonical order' |
| 276 |
in which the keys are sorted alphabetically. If this option |
| 277 |
is set to <constant>false</constant>, then the natural order |
| 278 |
is used, i.e. the object name as it was registered. This |
| 279 |
option can be overridden with a query parameter of the same |
| 280 |
name. |
| 281 |
</td> |
| 282 |
<td> |
| 283 |
Default: <constant>true</constant> |
| 284 |
</td> |
| 285 |
</tr> |
| 286 |
<tr> |
| 287 |
<td><constant>includeStackTrace</constant></td> |
| 288 |
<td> |
| 289 |
Whether to include a stacktrace of an exception in case of |
| 290 |
an error. By default it it set to <constant>true</constant> |
| 291 |
in which case the stacktrace is always included. If set to |
| 292 |
<constant>false</constant>, no stacktrace is included. If |
| 293 |
the value is <constant>runtime</constant> a stacktrace is |
| 294 |
only included for RuntimeExceptions. This global option can |
| 295 |
be overridden with a query parameter. |
| 296 |
</td> |
| 297 |
<td> |
| 298 |
Default: <constant>true</constant> |
| 299 |
</td> |
| 300 |
</tr> |
| 301 |
<tr> |
| 302 |
<td><constant>serializeException</constant></td> |
| 303 |
<td> |
| 304 |
When this parameter is set to <constant>true</constant>, |
| 305 |
then an exception thrown will be serialized as JSON and |
| 306 |
included in the response under the key |
| 307 |
<constant>error_value</constant>. No stacktrace information |
| 308 |
will be included, though. This global option can be |
| 309 |
overridden by a query parameter of the same name. |
| 310 |
</td> |
| 311 |
<td> |
| 312 |
Default: <constant>false</constant> |
| 313 |
</td> |
| 314 |
</tr> |
| 315 |
<tr> |
| 316 |
<td><constant>allowErrorDetails</constant></td> |
| 317 |
<td> |
| 318 |
If set to <constant>true</constant> then no error details like a stack trace |
| 319 |
(when <constant>includeStackTrace</constant> is set) or a serialized exception |
| 320 |
(when <constant>serializeExceptin</constant> is set) are included. This can be user as |
| 321 |
a startup option to avoid exposure of error details regardless of other options. |
| 322 |
</td> |
| 323 |
<td> |
| 324 |
Default: <constant>true</constant> |
| 325 |
</td> |
| 326 |
</tr> |
| 327 |
<tr> |
| 328 |
<td><constant>detectorOptions</constant></td> |
| 329 |
<td> |
| 330 |
Extra options passed to an detector after successful |
| 331 |
detection of an application server. See below for an |
| 332 |
explanation. |
| 333 |
</td> |
| 334 |
<td> |
| 335 |
</td> |
| 336 |
</tr> |
| 337 |
<tr> |
| 338 |
<td><constant>discoveryEnabled</constant></td> |
| 339 |
<td> |
| 340 |
Is set to <literal>true</literal> then this servlet will |
| 341 |
listen for multicast request (multicast-group 239.192.48.84, |
| 342 |
port 24884 by default, but can be changed). By default this option is disabled in order to |
| 343 |
avoid conflicts with an Java EE standards (though this should't |
| 344 |
harm anyways). This option can also be switched on with an |
| 345 |
environment variable |
| 346 |
<literal>JOLOKIA_DISCOVERY</literal> or the system |
| 347 |
property <literal>jolokia.discoveryEnabled</literal> set to |
| 348 |
<literal>true</literal>. |
| 349 |
</td> |
| 350 |
<td> |
| 351 |
Default: <constant>false</constant> |
| 352 |
</td> |
| 353 |
</tr> |
| 354 |
<tr> |
| 355 |
<td><constant>discoveryAgentUrl</constant></td> |
| 356 |
<td> |
| 357 |
Sets the URL to respond for multicast discovery requests. If |
| 358 |
given, <constant>discoveryEnabled</constant> is set |
| 359 |
implicetly to true. This URL can also be provied by an |
| 360 |
environment variable |
| 361 |
<literal>JOLOKIA_DISCOVERY_AGENT_URL</literal> or the system |
| 362 |
property <literal>jolokia.discoveryUrl</literal>. Within the value you can use the |
| 363 |
placeholders <literal>${host}</literal> and <literal>${ip}</literal> which gets replaced |
| 364 |
by the autodetected local host name/address. Also with <literal>${env:ENV_VAR}</literal> and |
| 365 |
<literal>${sys:property}</literal> environment and system properties can be referenced, respectively. |
| 366 |
</td> |
| 367 |
<td> |
| 368 |
<constant>http://10.9.11.87:8080/jolokia</constant> |
| 369 |
</td> |
| 370 |
</tr> |
| 371 |
<tr> |
| 372 |
<td><constant>multicastGroup</constant></td> |
| 373 |
<td>The multicast group IPv4 address. This group IP can be also given as an environment variable <literal>JOLOKIA_MULTICAST_GROUP</literal> or a system property <literal>jolokia.multicastGroup</literal></td> |
| 374 |
<td><constant>239.192.48.84</constant></td> |
| 375 |
</tr> |
| 376 |
<tr> |
| 377 |
<td>The multicast port. This port can be also given as an environment variable <literal>JOLOKIA_MULTICAST_PORT</literal> or a system property <literal>jolokia.multicastPort</literal></td> |
| 378 |
<td>The multicast port.</td> |
| 379 |
<td><constant>24884</constant></td> |
| 380 |
</tr> |
| 381 |
<tr> |
| 382 |
<td><constant>agentId</constant></td> |
| 383 |
<td> |
| 384 |
A unique ID for this agent. By default a unique id is |
| 385 |
calculated. If provided it should be ensured that this id is |
| 386 |
unique among all agent reachable via multicast requests used |
| 387 |
by the discovery mechanism. It is recommended not to set |
| 388 |
this value. Within the <literal>agentId</literal> specification you |
| 389 |
can use the same placeholders as in <literal>discoveryAgentUrl</literal>. |
| 390 |
</td> |
| 391 |
<td> |
| 392 |
<constant>my-unique-agent-id</constant> |
| 393 |
</td> |
| 394 |
</tr> |
| 395 |
<tr> |
| 396 |
<td><constant>agentDescription</constant></td> |
| 397 |
<td> |
| 398 |
An optional description which can be used for clients to |
| 399 |
present a human readable label for this agent. |
| 400 |
</td> |
| 401 |
<td> |
| 402 |
<constant>Monitoring agent</constant> |
| 403 |
</td> |
| 404 |
</tr> |
| 405 |
</table> |
| 406 |
<para> |
| 407 |
Jolokia has various detectors which can detect the brand and |
| 408 |
version of an application server it is running in. This version |
| 409 |
is revealed with the <constant>version</constant> command. With |
| 410 |
the configuration parameter <constant>detectorOptions</constant> |
| 411 |
extra options can be passed to the detectors. These options take |
| 412 |
the form of a JSON object, where the keys are productnames and |
| 413 |
the values other JSON objects containing the specific |
| 414 |
configuration. This configuration is feed to a successful |
| 415 |
detector which can do some extra initialization on agent |
| 416 |
startup. Currently the following extra options are supported: |
| 417 |
</para> |
| 418 |
<table id="agent-war-detector-options"> |
| 419 |
<title>Detector Options</title> |
| 420 |
<thead> |
| 421 |
<tr> |
| 422 |
<td>Product</td> |
| 423 |
<td>Option</td> |
| 424 |
<td>Description</td> |
| 425 |
</tr> |
| 426 |
</thead> |
| 427 |
<tr> |
| 428 |
<td>glassfish</td> |
| 429 |
<td>bootAmx</td> |
| 430 |
<td>If <constant>false</constant> and the agent is running on |
| 431 |
Glassfish, this will cause the AMX subsystem not to be booted |
| 432 |
during startup. By default, AMX which contains all relevant |
| 433 |
MBeans for monitoring Glassfish is booted. |
| 434 |
</td> |
| 435 |
</tr> |
| 436 |
</table> |
| 437 |
</section> |
| 438 |
<section id="agent-war-security"> |
| 439 |
<title>Security Setup</title> |
| 440 |
<para> |
| 441 |
The WAR agent comes in two flavors: |
| 442 |
</para> |
| 443 |
<variablelist> |
| 444 |
<varlistentry> |
| 445 |
<term><emphasis role="bold">jolokia.war</emphasis></term> |
| 446 |
<listitem> |
| 447 |
The standard agent which is secured with the role "jolokia". You have to setup your servlet container |
| 448 |
to connect this role to the authentication. |
| 449 |
</listitem> |
| 450 |
</varlistentry> |
| 451 |
<varlistentry> |
| 452 |
<term><emphasis role="bold">jolokia-unsecured.war</emphasis></term> |
| 453 |
<listitem> |
| 454 |
A demo agent, which is completely unsecured. Please use this agent only for evaluation purposes, but it is |
| 455 |
highly recommended that use the security enabled agent <emphasis>jolokia.war</emphasis> |
| 456 |
</listitem> |
| 457 |
</varlistentry> |
| 458 |
</variablelist> |
| 459 |
|
| 460 |
<para> |
| 461 |
Java EE security is enabled by default by adding the required information within the |
| 462 |
<filename>web.xml</filename>.<sidebar> |
| 463 |
<title>Using jmx4perl's <literal>jolokia</literal> tool</title> |
| 464 |
<ulink url="http://www.jmx4perl.org">jmx4perl</ulink> comes |
| 465 |
with a nice command line utility called <ulink |
| 466 |
url="http://search.cpan.org/~roland/jmx4perl/scripts/jolokia">jolokia</ulink> |
| 467 |
which allows for an easy setup of security within a given |
| 468 |
<filename>jolokia.war</filename>. See <xref linkend="tools-jmx4perl"/> for |
| 469 |
more details. |
| 470 |
</sidebar> |
| 471 |
All |
| 472 |
current client libraries are able to use BASIC HTTP authentication |
| 473 |
with user and password. The |
| 474 |
<literal><login-config></literal> should be set |
| 475 |
accordingly. The <literal><security-constraint></literal> |
| 476 |
specifies the URL pattern (which is in the default setup specify |
| 477 |
all resources provided by the Jolokia servlet) and a role name "jolokia" |
| 478 |
which is used to find the proper authentication credentials. This |
| 479 |
role must be referenced outside the agent WAR within the servlet |
| 480 |
container, e.g. for Tomcat the role definition can be found in |
| 481 |
<filename>$TOMCAT/config/tomcat-users.xml</filename>. |
| 482 |
</para> |
| 483 |
</section> |
| 484 |
|
| 485 |
<section id="agent-war-programmatic"> |
| 486 |
<title>Programmatic usage of the Jolokia agent servlet</title> |
| 487 |
<para> |
| 488 |
The Jolokia agent servlet can be integrated into one's own |
| 489 |
web-applications as well. Simply add a servlet with |
| 490 |
the servlet class |
| 491 |
<classname>org.jolokia.http.AgentServlet</classname> to your |
| 492 |
own <filename>web.xml</filename>. The following example maps |
| 493 |
the agent to the context <literal>/jolokia</literal>: |
| 494 |
</para> |
| 495 |
<programlisting language="xml"><![CDATA[ |
| 496 |
<servlet> |
| 497 |
<servlet-name>jolokia-agent</servlet-name> |
| 498 |
<servlet-class>org.jolokia.http.AgentServlet</servlet-class> |
| 499 |
<load-on-startup>1</load-on-startup> |
| 500 |
</servlet> |
| 501 |
|
| 502 |
<servlet-mapping> |
| 503 |
<servlet-name>jolokia-agent</servlet-name> |
| 504 |
<url-pattern>/jolokia/*</url-pattern> |
| 505 |
</servlet-mapping> |
| 506 |
]]></programlisting> |
| 507 |
<para> |
| 508 |
Of course, any init parameter as described in <xref |
| 509 |
linkend="agent-war-init-params"/> can be used here as well. |
| 510 |
</para> |
| 511 |
<para> |
| 512 |
In order for this servlet definition to find the referenced |
| 513 |
Java class, the JAR <filename>jolokia-core.jar</filename> must |
| 514 |
be included. This jar can be found in <ulink |
| 515 |
url="http://repo1.maven.org/maven2/org/jolokia/jolokia-core">Maven central |
| 516 |
</ulink>. Maven users will can declare a |
| 517 |
dependency on this jar artifact: |
| 518 |
</para> |
| 519 |
<programlisting language="xml"><![CDATA[ |
| 520 |
<project> |
| 521 |
<!-- .... --> |
| 522 |
<dependencies> |
| 523 |
<dependency> |
| 524 |
<groupId>org.jolokia</groupId> |
| 525 |
<artifactId>jolokia-core</artifactId> |
| 526 |
<version>${jolokia.version}</version> |
| 527 |
</dependency> |
| 528 |
</dependencies> |
| 529 |
<!-- .... --> |
| 530 |
</project>]]></programlisting> |
| 531 |
<para> |
| 532 |
The <classname>org.jolokia.http.Agent</classname> can be |
| 533 |
subclassed, too in order to provide a custom restrictor or a |
| 534 |
custom log handler. See <xref linkend="security-restrictor"/> |
| 535 |
for details.<footnote> |
| 536 |
<para> |
| 537 |
Replace |
| 538 |
<classname>org.jolokia.osgi.http.AgentServlet</classname> with |
| 539 |
<classname>org.jolokia.http.AgentServlet</classname> to use |
| 540 |
the servlet in a non-OSGi environment. |
| 541 |
</para> |
| 542 |
</footnote> |
| 543 |
</para> |
| 544 |
<para> |
| 545 |
Also, multiple Jolokia agents can be deployed in the same JVM |
| 546 |
without problem. However, since the agent deploys some |
| 547 |
Jolokia-specific MBeans on the single |
| 548 |
<literal>PlatformMBeansServer</literal>, for multi-agent |
| 549 |
deployments it is important to use the |
| 550 |
<constant>mbeanQualifier</constant> init parameter to |
| 551 |
distinguish multiple Jolokia MBeans by adding an extra |
| 552 |
propery to those MBeans' names. This also needs to be done if |
| 553 |
multiple webapps containing Jolokia agents are deployed on |
| 554 |
the same Java EE server. |
| 555 |
</para> |
| 556 |
</section> |
| 557 |
</section> |