4 Replies Latest reply on Sep 26, 2012 6:38 AM by wdfink

    How to get the JBoss Start time

    danielgalan

      Hello,

      I need to get the time jboss starts, before deploying or anything else.
      The Information will be needed in a Scheduler.

      We are using JBoss 3.2.6 (we will switch to 4.0 soon, but it has to work on both, maybe there is no difference, just to let you know).

      Thanks
      Daniel

        • 1. Re: How to get the JBoss Start time
          peterj

          Look at the StartDate attribute of the jboss.system:type=Server MBean (caveat: I am using 5.0 beta 1, not sure if 3.2.x has that attribute)

          • 2. Re: How to get the JBoss Start time
            danielgalan

            Thanks Peter,

            ObjectName mbeanId = new ObjectName("jboss.system:type=Server");
            MBeanServer server = MBeanServerLocator.locateJBoss();
            Date startDate = (Date)server.getAttribute(new ObjectName("jboss.system:type=Server"), "StartDate");
            Date jbossStartupTime = new Date(System.currentTimeMillis() - startDate.getTime());
            


            so thats the way I receive the Startuptime now.

            Bye

            • 3. Re: How to get the JBoss Start time
              mcallaf

              Hello,

              I'm having the same need, i tried this proposal but it gives me an IllegalStateExeption:

              Exception in thread "main" java.lang.IllegalStateException: No 'jboss' MBeanServer found!

               

              Do i have to add something in my standalone.xml?

               

              ** I'm using JBOSS 7.1.1 final

              Thank you.

              • 4. Re: How to get the JBoss Start time
                wdfink

                You can read the start-time attribute from the CLI with '/core-service=platform-mbean/type=runtime:read-attribute( name=start-time)'.

                 

                BTW you should create a new thread instead of using such old one because the server will be complete different.