PDA

View Full Version : Spring managed MBeans to JBoss(4.0.2) MBean sever issue.


nkaranuk
Dec 29th, 2005, 02:38 AM
Hello,
I had to make Spring managed MBeans accessible thru Jboss's jmx-console and so used following conf
---applicationContext.xml---

<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
<property name="beans">
<map>
<entry key="bean:name=TestMBean"> <ref bean="testBean" /></entry>
</map>
</property>
</bean>
<bean id="testBean" class="com.acme.Test"/>

Has bellow in the web.xml

<listener> <listener-class>org.springframework.web.context.ContextLoaderListe ner</listener-class>
</listener>

but when the war is deployed get stack trace
2005-12-29 13:01:22,730 ERROR [org.springframework.web.context.ContextLoader] Context initialization failed
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'exporter' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.jmx.MBeanServerNotFoundExcepti on: Unable to locate an MBeanServer instance
org.springframework.jmx.MBeanServerNotFoundExcepti on: Unable to locate an MBeanServer instance
at org.springframework.jmx.support.JmxUtils.locateMBe anServer(JmxUtils.java:81)
at org.springframework.jmx.support.JmxUtils.locateMBe anServer(JmxUtils.java:63)
at org.springframework.jmx.export.MBeanExporter.regis terBeans(MBeanExporter.java:332)
at org.springframework.jmx.export.MBeanExporter.after PropertiesSet(MBeanExporter.java:312)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1058)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:363)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:226)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:147)

Plz let me know if i'm making some configurations mistake,as per http://blogs.warwick.ac.uk/chrismay/entry/spring_jmx_integration/ the conf does seem right.

looking forward for ur thoughts,
nkaranuk

Costin Leau
Dec 29th, 2005, 04:55 AM
The exporter doesn't find the JBoss JMX server, either make the exporter to create one automatically (see the javadocs) or search the forums - this issues has been discussed a couple of time, IIRC.

nkaranuk
Dec 29th, 2005, 06:03 AM
Hi Costin,
My main intention was to have spring-managed mbean registered to the the JBoss's JMX server and to access from jboss's jmx-console.This app is being deployed on a JBoss AS which already has a jmx server.
Before posting this i went thru forums/doc but all seemed to revolve arnd http://static.springframework.org/spring/docs/1.2.x/reference/jmx.html implying that that org.springframework.jmx.export.MBeanExporter will automaticatically register the mBean to the existing MBean server.
plz correct me if i'm wrong.But the Jboss's jmx server seems to be not picked up by MBeanExporter

looking forward for ur thoughts,
nkaranuk

Costin Leau
Dec 29th, 2005, 06:31 AM
I haven't used JBoss in while so my advices are based on my experience with the exported code and usage outside of it...
Yes, the JBoss JMX server is not being picked up automatically so you have to do some debugging to make sure that it's started before Spring appContext is deployed. Find also the ID of the server - you can pass this string to exported.
Use also some other consoles like mc4j or jconsole to browse the server and find its exact address.