Announcement Announcement Module
Collapse
No announcement yet.
Empty 'beans' map property of MBeanExporter Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Empty 'beans' map property of MBeanExporter

    Why does the 'beans' map property of the MBeanExporter have to be non-empty? I want to use the MBeanExporter for exporting MBeans at runtime (calling the registerManagedResource method).

    Kind regards
    Juergen

  • #2
    Hi Juergen

    So far as I can tell the 'beans' property can be empty. What is the error that you are getting, or where are you reading that the 'beans' map must be non-empty? What version of Spring are you using?

    Cheers
    Rick

    Comment


    • #3
      Hi Rick!

      I'm using Spring Version 2.0.5 and getting the following exception:

      Code:
      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'statistik_exporter' defined in class path resource [at/sozvers/stp/zpv/verst/app/jmx/TestKontextDynamicJMX.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Must specify at least one bean for registration
      Caused by: java.lang.IllegalArgumentException: Must specify at least one bean for registration
      	at org.springframework.jmx.export.MBeanExporter.registerBeans(MBeanExporter.java:491)
      	at org.springframework.jmx.export.MBeanExporter.afterPropertiesSet(MBeanExporter.java:388)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1202)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1172)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:428)
      	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
      	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
      	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:287)
      	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
      	at org.springframework.test.AbstractSingleSpringContextTests.createApplicationContext(AbstractSingleSpringContextTests.java:199)
      	at org.springframework.test.AbstractSingleSpringContextTests.loadContextLocations(AbstractSingleSpringContextTests.java:179)
      	at org.springframework.test.AbstractSingleSpringContextTests.loadContext(AbstractSingleSpringContextTests.java:158)
      	at org.springframework.test.AbstractSpringContextTests.getContext(AbstractSpringContextTests.java:105)
      	at org.springframework.test.AbstractSingleSpringContextTests.setUp(AbstractSingleSpringContextTests.java:87)
      	at junit.framework.TestCase.runBare(TestCase.java:125)
      	at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)
      	at junit.framework.TestResult$1.protect(TestResult.java:106)
      	at junit.framework.TestResult.runProtected(TestResult.java:124)
      	at junit.framework.TestResult.run(TestResult.java:109)
      	at junit.framework.TestCase.run(TestCase.java:118)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
      Spring configuration:

      Code:
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
      <beans>
      
      	<bean id="mbeanServer" 
      	 	class="org.springframework.jmx.support.MBeanServerFactoryBean">
      	
      		<property name="locateExistingServerIfPossible" value="false"/>
      		<property name="defaultDomain" value="at.sozvers.stp.zpv.verst.test"/>
      	</bean>
      	
      	<bean id="registry" 
      		class="org.springframework.remoting.rmi.RmiRegistryFactoryBean">
      		<property name="port" value="61100"/>
      	</bean>
      	
      	<bean id="serverConnector" 
      		class="org.springframework.jmx.support.ConnectorServerFactoryBean">
      		
      		<property name="objectName" value="connector:name=rmi"/>
        		<property name="serviceUrl" 
                     value="service:jmx:rmi://localhost/jndi/rmi://localhost:61100/zpvversttest"/>
      	</bean>
      
      	<bean id="statistik_exporter"
      		class="org.springframework.jmx.export.MBeanExporter">
      		<!-- 
      		<property name="beans">
      			<map>
      				<entry key="at.sozvers.stp.zpv.verst.test:name=Statistik">
      					<ref local="jmxVerstaendigungsStatistik" />
      				</entry>
      			</map>
      		</property>
      		-->
      		<property name="assembler">
      			<bean
      				class="org.springframework.jmx.export.assembler.InterfaceBasedMBeanInfoAssembler">
      				<property name="managedInterfaces">
      					<value>at.sozvers.stp.zpv.verst.app.jmx.JMXVerstaendigungStatistik</value>
      				</property>
      			</bean>
      		</property>
      	</bean>
      	
      	<bean id="jmxVerstaendigungsStatistik"
      		class="at.sozvers.stp.zpv.verst.app.jmx.VerstaendigungStatistikJMXBean">
      		
      		<property name="statistik" ref="jobsStatistik"/>
      	</bean>
      	
      	<bean id="jobsStatistik" 
      		class="at.sozvers.stp.zpv.bc.verstaend.impl.schedule.StdVerstaendigungJobStatistik">
      	</bean>
      	
      </beans>
      Kind regards
      Juergen

      Originally posted by Rick Evans View Post
      Hi Juergen

      So far as I can tell the 'beans' property can be empty. What is the error that you are getting, or where are you reading that the 'beans' map must be non-empty? What version of Spring are you using?

      Cheers
      Rick

      Comment


      • #4
        Hi Juergen

        Ah... that would be it then. Yeah, the whole requirement that 'you absolutely must have at least 1 bean in the beans map' was removed in versions of Spring later than 2.0.5 (Mainly because it was considered an odd requirement... why should you be forced to expose 1 bean declaratively?)

        http://springframework.cvs.sourcefor...1=1.46&r2=1.47

        The latest version of Spring in the 2.0.x line does not have this requirement anymore. If possible, you should upgrade to a later version of Spring (such as 2.0.6... I think the requirement is gone in 2.0.6... it is definitely gone in the 2.0.7 HEAD). If you cannot upgrade then... mmm; perhaps you can patch the MBeanExporter for the moment?

        Cheers
        Rick

        Comment

        Working...
        X