[jboss-jira] [JBoss JIRA] (WFLY-3054) getPlatformMBeanServer behaves badly when called from premain class such as jmxetric

Kabir Khan (JIRA) issues at jboss.org
Fri Mar 7 07:24:33 EST 2014


    [ https://issues.jboss.org/browse/WFLY-3054?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12951092#comment-12951092 ] 

Kabir Khan commented on WFLY-3054:
----------------------------------

I believe that the platform mbean server can only be swapped out on the initial call to ManagementFactory.getPlatformMBeanServer(), and jboss-modules needs to set that, unless you can figure out how to do that the same way from your code.

Alternatively, perhaps an alternative premain method which waits for the actual class passed in to jboss-modules as the main, before calling getPlatformMBeanServer() could work. By that stage jboss-modules should have set the platform mbean server. In the case of a standalone server the name of the main class is 'org.jboss.as.server.Main'. Apart from that I don't really think there is a lot we can do.


                
> getPlatformMBeanServer behaves badly when called from premain class such as jmxetric
> ------------------------------------------------------------------------------------
>
>                 Key: WFLY-3054
>                 URL: https://issues.jboss.org/browse/WFLY-3054
>             Project: WildFly
>          Issue Type: Enhancement
>      Security Level: Public(Everyone can see) 
>          Components: JMX
>    Affects Versions: JBoss AS7 7.1.1.Final
>            Reporter: dpocock
>            Assignee: Kabir Khan
>              Labels: jboss
>
> JMXetric is a management agent JAR loaded using the JVM argument 
> java -javaagent:$JARLIBS/jmxetric-1.0.2.jar .....
> In the premain method (executed before JBoss main() is invoked), jmxetric calls the static method:
>    ManagementFactory.getPlatformMBeanServer()
> This puts JMX into a bad state and the jboss.as tree is completely missing when browsed with jconsole
> As a workaround, jmxetric will defer the call to ManagementFactory.getPlatformMBeanServer() using the "initialdelay" parameter set to a value such as 20 seconds.
> However, it would be good if JBoss could act more cleanly in this situation, for example, throwing an exception if ManagementFactory.getPlatformMBeanServer() is called too early, or finding a way to add the "jboss.as" stuff later.
> The 1.0.6 release of jmxetric will include the workaround by default.  The bug can be reproduced by setting initialdelay="0" in the sample jmxetric.xml or using jmxetric 1.0.5
> jmxetric versions before 1.0.5 suffer from issues with the jboss logger as discussed in WFLY-895, so this issue was only discovered after removing the logging statements from jmxetric.
> Also covered in jmxetric github:
> https://github.com/ganglia/jmxetric/issues/9

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jboss-jira mailing list