PDA

View Full Version : MBean not showing



daune_jf
Sep 18th, 2006, 05:07 AM
Hi,

I defined a JBoss SAR that creates a ClassPathXmlApplicationContext based on three files: 1.xml, 2.xml, 3.xml.

In 1.xml, I define this:

<bean id="jmxExporter" class="org.springframework.jmx.export.MBeanExporter" lazy-init="false">
<property name="autodetect" value="true" />
<property name="assembler">
<bean class="org.springframework.jmx.export.assembler.MetadataM BeanInfoAssembler">
<property name="attributeSource" ref="jmxAttributeSource" />
</bean>
</property>
<property name="namingStrategy">
<bean class="org.springframework.jmx.export.naming.MetadataNami ngStrategy">
<property name="attributeSource" ref="jmxAttributeSource" />
</bean>
</property>
</bean>

<bean id="jmxAttributeSource" class="org.springframework.jmx.export.annotation.Annotati onJmxAttributeSource"/>

In both 1.xml and 2.xml, I define beans having @ManagedResource annotation.

MBeans defined in 1.xml are showing, but those in 2.xml are not.

Has anyone an idea about what's wrong?

Regards,

J-F

daune_jf
Sep 18th, 2006, 05:10 AM
<bean id="jmxExporter" class="org.springframework.jmx.export.MBeanExporter" lazy-init="false">
<property name="autodetect" value="true" />
<property name="assembler">
<bean class="org.springframework.jmx.export.assembler.MetadataM BeanInfoAssembler">
<property name="attributeSource" ref="jmxAttributeSource" />
</bean>
</property>
<property name="namingStrategy">
<bean class="org.springframework.jmx.export.naming.MetadataNami ngStrategy">
<property name="attributeSource" ref="jmxAttributeSource" />
</bean>
</property>
</bean>

<bean id="jmxAttributeSource" class="org.springframework.jmx.export.annotation.Annotati onJmxAttributeSource"/>

daune_jf
Sep 18th, 2006, 06:51 AM
OK, I have found the problem.

It appears that beans cannot be embedded such as


<bean id="myBean" class="...">
<property name="theDependency">
<bean class="ClassThatMustBeExported"/>
</property>
</bean>


The instance of ClassThatMustBeExported must be declared in a separate top-level bean clause.

The fact that exporter was defined in one file and the bean in another is irrelevant.

J-F