Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Trouble with Spring JMX with JBoss 4.0.3

  1. #1
    Join Date
    Aug 2004
    Location
    Wellington, New Zealand
    Posts
    31

    Default Trouble with Spring JMX with JBoss 4.0.3

    I'm trying to get my application's Spring-exported JMX beans to show up in both jconsole and in the JBoss JMX console under Java 1.5. To that end, I've configured JBoss to use the platform MBeanServer, as described here

    http://wiki.jboss.org/wiki/Wiki.jsp?...eansInJConsole

    After doing this and starting up JBoss, as JBoss is starting up if I attach to the MBeanServer using jconsole, I see all the standard Java MBeans loaded, as well as JBoss MBeans load. When Spring finally exports my application's MBeans, however, all MBeans disappear from jconsole _except_ my application's MBeans and one named JMImplementation:name=MBeanServerDelegate. The same beans are also what show up in JBoss's web /jmx-console.

    If I don't configure JBoss to use the platform MBeanServer, but leave the -Dcom.sun.management.jmxremote flag for the JVM, then the Spring-exported beans show up in jconsole only, and all the JBoss beans show up in the /jmx-console only.

    If I don't have the -Dcom.sun.management.jmxremote configured at all for JBoss, then the Spring-exported beans and all the JBoss beans show up together in the /jmx-console.

    What I'd really like is for all beans to show up using jconsole as well as the /jmx-console. Anybody have any luck with this?
    -- m@

  2. #2
    Join Date
    Sep 2005
    Posts
    21

    Default

    Funny I am working on the same problem on the same day.
    I have a Spring application where there is a org.springframework.jmx.access.MBeanProxyFactoryBe an pointing to one of Jboss's Mbeans.

    Everything worked great up until I put -D com.sun.management.jmxremote in the Jboss startup script to be able to use jconsole. At this point, application fails to deploy with the javax.management.InstanceNotFoundException basically telling me that MBean in question is not found.

    Prior in the log there is the following (bean name obscured):
    16:37:26,952 INFO [DefaultListableBeanFactory] Creating shared instance of singleton bean '..MBean'
    16:37:26,972 WARN [JmxUtils] Found more than one MBeanServer instance. Returning first from list.

    This leads me to believe that Mbean server deployed by jconsole interferes with Jboss mbean server.

    Is there a way to tell Spring which Mbean server to use? Any other suggestions?

  3. #3
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    What's your configuration? JmxUtils has a method for searching an mbean server with a given agentId - you can use that yourself to give the exporter the approapriate server using the factory support inside the XML app context.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  4. #4
    Join Date
    Aug 2004
    Location
    Wellington, New Zealand
    Posts
    31

    Default

    I found the problem for me, it had to do with two MBeanServer's being created. I had a class that contained

    Code:
    private final MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer("system-tool");
    which caused two instances of JBoss's org.jboss.system.server.jmx.LazyMBeanServer to be created. When I removed the code that created the system-tool MBeanServer, the problem went away and all JBoss beans, JDK beans, and my application beans show up in JConsole as well as /jmx-console.

    This must be more of an issue with JBoss's code, not Spring's.
    -- m@

  5. #5
    Join Date
    Aug 2004
    Location
    Sydney
    Posts
    503

    Default

    This must be more of an issue with JBoss's code, not Spring's.
    Is there a rule saying that only one MBeanServer can be created? -- I don't think so.

    Given that the entire JBoss architecture is based around JMX, and they were the first to do this, I'd expect they know what they're doing when it comes to JMX.

    I think what costin said is more along the right track.

  6. #6
    Join Date
    Aug 2004
    Location
    Wellington, New Zealand
    Posts
    31

    Default

    Quote Originally Posted by gmatthews
    Is there a rule saying that only one MBeanServer can be created? -- I don't think so.
    Nor did I suggest that. I'm merely saying that the way JBoss 4.0.3 integrates the JDK 1.5 platform MBeanServer with it's own implementation has some twists that I need to work around.

    Quote Originally Posted by gmatthews
    I think what costin said is more along the right track.
    I haven't found the way to get the JBoss MBeanServer instance's agentId to pass this to Spring (but I haven't looked thoroughly) so I can't say if that does anything to work around the problem or not. If you know an easy way to get the agentId, I'd be happy to try it out.
    -- m@

  7. #7
    Join Date
    Aug 2004
    Location
    Sydney
    Posts
    503

    Default

    I think this thread may need to be turned into a Jira request.

    The 3 complicating factors are that:

    1. You may or may not be using java5, and have used the flag to cause the VM to start an MBeanServer

    2. You may or may not be using an appserver or other container that starts it's own MBeanServer

    3. There may be multiple MBeanServers

    I haven't looked that thoroughly either, but there's a public void setServer(MBeanServer server) method in org.springframework.jmx.export.MBeanExporter

    If no magic Spring class exists, would it be possible to create your own factory to supply an MBeanServer, based on querying whatever environment you know you'll be running in?

  8. #8
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    What about using setServer along with JMXUtils.locateMBeanServer; smth like (from the tip of my head):

    Code:
    <bean id="jmxExporter" class="org.springframework.jmx.export.MBeanExporter"
            lazy-init="false">
        <property name="server">
          <bean class="org.springframework.jmx.JmxUtils" factory-method="locateMBeanServer">
             <constructor-arg value="myJmxMBeanServerName"/>
          </bean>
        </property>
    </bean>
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  9. #9
    Join Date
    Aug 2004
    Location
    Wellington, New Zealand
    Posts
    31

    Default

    Quote Originally Posted by costin
    What about using setServer along with JMXUtils.locateMBeanServer; smth like (from the tip of my head):

    Code:
    <bean id="jmxExporter" class="org.springframework.jmx.export.MBeanExporter"
            lazy-init="false">
        <property name="server">
          <bean class="org.springframework.jmx.JmxUtils" factory-method="locateMBeanServer">
             <constructor-arg value="myJmxMBeanServerName"/>
          </bean>
        </property>
    </bean>
    The trouble is I don't know a way to find out JBoss' agentId. I think the issues still comes back to the way JBoss integrates into the Java 5 platform MBeanServer. Since to do this you have to use JBoss's MBeanServerBuilder (i.e. -Djavax.management.builder.initial=org.jboss.system .server.jmx.MBeanServerBuilderImpl), and then creating servers with MBeanServerFactory.createMBeanServer("foo") creates multiple instances of JBoss' LazyMBeanServer, which JBoss doesn't seem to deal well with.

    In the end, I'm just looking for an existing MBeanServer and using that if it exists. That solves the issue.
    -- m@

  10. #10
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    You can take a look at the code inside JmxUtils to see how to list the mbean servers in the current jvm. The MBeanServerBuilder from JBoss most probably does decoration - you can find more about this in the JMX and MX4J documentation.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •