geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Deepak Srinivasa" <>
Subject Re: When has the server started?
Date Sun, 03 Sep 2006 04:38:04 GMT
Hi Jason,

I was interested too, in finding out this piece of information from my

In Geronimo 1.0, the code below '' works. It basically
gets hold of the Kernel, then gets a KernelManagementHelper object, and then
queries for the JVM, to find out its boot time (I am assuming that JVM start
time is close to what you are looking for).

However, in Geronimo 1.1, this fails. I am able to get the
KernelManagementHelper object, and also able to look up the domains. But I
cannot get the servers from the first domain.

In jconsole, I wish that the VM tab was active. The VM tab gives info about
the uptime of VM (I have seen that when I ran jconsole to see JMX info for
other software). Then, we could have done currentTime-upTime to get the boot

If you are successful in getting server configuration information from JMX,
please let me know how you did that. Thanks!


------------- -----------------
import java.util.Date;


import org.apache.geronimo.console.util.KernelManagementHelper;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.jmx.KernelDelegate;

public class ServerWhenStart {

     * @param args
    public static void main(String[] args) throws Exception{
        // TODO Auto-generated method stub

        java.util.Map environment = new java.util.HashMap();
        String[] credentials = new String[]{"system", "manager"};
        environment.put(JMXConnector.CREDENTIALS, credentials);
        JMXServiceURL address = new
        JMXConnector jmxConnector = JMXConnectorFactory.connect(address,
        MBeanServerConnection mbServerConnection =
        Kernel kernel = new KernelDelegate(mbServerConnection);

        KernelManagementHelper mgr = new KernelManagementHelper(kernel);
        J2EEDomain domain = mgr.getDomains()[0];

        //This is where it fails
        J2EEServer[] server = mgr.getServers(domain)[0];
        JVM[] jvms = mgr.getJavaVMs(server);

        //I am thinking that the first VM is what we are interested in...
(is that right??)
        JVM jvm = jvms[0];
        Date bootTime = jvm.getKernelBootTime();



On 9/2/06, Jason Dillon <> wrote:
> What is the best way to detect when the server has started using JMX?
> The ServerBehavior class in the deployment plugin has some code that
> connects to JMX, then lists the configurations, and then takes he
> first configuration and get the "kernelFulltStarted" attribute from
> it... but it assumes that ConfigurationManager.listConfigurations()
> returns an array of ObjectNames, which it does not.
> I also peeked at the server's JMX tree via jconsole and I don't see
> any attribute or operation that matches up to "kernelFullyStarted".
> There is also a strange "null" element of the tree, but I will leave
> that for another day.
> So, how can I easily check of the server has started by polling a JMX
> attribute?
> --jason

View raw message