JMX connection to Java CAPS 5.1.3 and 6
Java CAPS 5.1.3
With Java CAPS 5.1.3 the default Java JMX agent is not active by default. You can follow the steps in this entry to enable the agent. If you cannot and don't want to modify the domain.xml configuration you can still connect to the Java CAPS built-in JMX agent. The protocol to access the JMX agent is based on the Sun Application Server 8 protocol because Java CAPS 5.1 was built around 2005, see here
The Java library that contains this custom protocol is contained in the "Deployment Command-Line Client". You can get it from your repository from the "Downloads" tab.
Get the deploycli.jar. As I am working with Groovy, I drop it in the groovy/lib folder. The following snippet shows how to connect to the JMX server:
Java CAPS 6 load the default Java JMX agent automatically. This is show in the server.log, for example:
So the url is easy to get. The JMX agent is protected by a password corresponding to the "admin" user. The following Groovy snippet shows how to connect:
Whichever method or release is used to obtain the JMX server connection the JMX API is the same for Repository based projects. Therefore the scripts presented here run the same whichever method is used to get the JMX connection.
With Java CAPS 5.1.3 the default Java JMX agent is not active by default. You can follow the steps in this entry to enable the agent. If you cannot and don't want to modify the domain.xml configuration you can still connect to the Java CAPS built-in JMX agent. The protocol to access the JMX agent is based on the Sun Application Server 8 protocol because Java CAPS 5.1 was built around 2005, see here
The Java library that contains this custom protocol is contained in the "Deployment Command-Line Client". You can get it from your repository from the "Downloads" tab.
Get the deploycli.jar. As I am working with Groovy, I drop it in the groovy/lib folder. The following snippet shows how to connect to the JMX server:
def connectJCAPS513() {
def url = 'service:jmx:s1ashttp://localhost:18000'
def env = [
"USER":"Administrator",
"PASSWORD":"STC",
"jmx.remote.protocol.provider.pkgs":"com.sun.enterprise.admin.jmx.remote.protocol",
"com.sun.enterprise.as.http.auth":"BASIC"
]
return getServer(url,env);
}
Java CAPS 6Java CAPS 6 load the default Java JMX agent automatically. This is show in the server.log, for example:
[#|2009-09-08T18:32:11.078+0200|INFO|sun-appserver9.1|javax.enterprise.system.tools.admin|_ThreadID=14;_ThreadName=Thread-16;service:jmx:rmi:///jndi/rmi://elerognon:8686/jmxrmi;|ADM1504: Here is the JMXServiceURL for the Standard JMXConnectorServer: [service:jmx:rmi:///jndi/rmi://elerognon:8686/jmxrmi]. This is where the remote administrative clients should connect using the standard JMX connectors|#]
So the url is easy to get. The JMX agent is protected by a password corresponding to the "admin" user. The following Groovy snippet shows how to connect:
def connectJCAPS6() {
def url = 'service:jmx:rmi:///jndi/rmi://localhost:8686/jmxrmi'
def env = [(JMXConnector.CREDENTIALS): (String[])["admin", "adminadmin"]]
return getServer(url,env);
}
ConclusionWhichever method or release is used to obtain the JMX server connection the JMX API is the same for Repository based projects. Therefore the scripts presented here run the same whichever method is used to get the JMX connection.

Nifty. Going to use this to monitor some thread pools in production. Thanks!
Posted by ioj on October 29, 2009 at 06:21 PM CET #