thornei
Dec 15th, 2005, 04:11 AM
Hi,
My requirement is this. I have a simple bean.
I would like to be able to administer the bean at runtime.
I'd like to use JMX for this as it is standard.
My bean lives in a simple standalone application that has access to a remote WebLogic MBeanServer, so after some searching these forums I found the
WebLogicMBeanServerFactoryBean class which seems to fit the bill.
What I'd like to do is register the simple bean (I've put the simple bean on
weblogic server's classpath) with the weblogic server, and then use mc4j to
try and update it's properties at runtime.
I'm trying to register the simple bean with the following config:
<bean id="mbeanServer" class="org.springframework.jmx.support.WebLogicMBeanServe rFactoryBean">
<property name="serverName">
<value>george</value>
</property>
</bean>
<bean id="testBean" class="com.deuba.multiplexer.TestBean">
<property name="age">
<value>100</value>
</property>
<property name="name">
<value>Yoda</value>
</property>
</bean>
<bean id="exportedMBeanService" class="org.springframework.jmx.export.MBeanExporter">
<property name="beans">
<map>
<entry key="db:Name=TestBean" value-ref="testBean"/>
</map>
</property>
<property name="server" ref="mbeanServer"/>
</bean>
but I get an exception (in full below) caused by:
java.io.NotSerializableException: javax.management.modelmbean.RequiredModelMBean
which suggests I'm doing something very wrong. Is there a way to achieve this in Spring? I've managed to do this writing the MBeanServer lookup and
MBean registration myself but that's just too much work isn't it? :)
INFO org.springframework.beans.factory.xml.XmlBeanDefin itionReader 09:29:59,356 [main]: Loading XML bean definitions from class path resource [multiplexer-example.xml]
INFO org.springframework.core.CollectionFactory 09:29:59,543 [main]: JDK 1.4+ collections available
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'exportedMBeanService' defined in class path resource [multiplexer-example.xml]: Initialization of bean failed; nested exception is weblogic.rmi.extensions.RemoteRuntimeException: Unexpected Exception
java.rmi.MarshalException: failed to marshal registerMBean(Ljava.lang.Object;Ljavax.management. ObjectName;); nested exception is:
java.io.NotSerializableException: javax.management.modelmbean.RequiredModelMBean
at weblogic.rjvm.BasicOutboundRequest.marshalArgs(Bas icOutboundRequest.java:86)
at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicR emoteRef.java:163)
at weblogic.management.internal.RemoteMBeanServerImpl _815_WLStub.registerMBean(Unknown Source)
at org.springframework.jmx.export.MBeanExporter.doReg ister(MBeanExporter.java:566)
at org.springframework.jmx.export.MBeanExporter.regis terSimpleBean(MBeanExporter.java:519)
at org.springframework.jmx.export.MBeanExporter.regis terBeanInstance(MBeanExporter.java:467)
at org.springframework.jmx.export.MBeanExporter.regis terBeanNameOrInstance(MBeanExporter.java:441)
at org.springframework.jmx.export.MBeanExporter.regis terBeans(MBeanExporter.java:368)
at org.springframework.jmx.export.MBeanExporter.after PropertiesSet(MBeanExporter.java:312)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1059)
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)
at com.deuba.multiplexer.StandaloneLauncher.main(Stan daloneLauncher.java:29)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main (AppMain.java:86)
Caused by: java.io.NotSerializableException: javax.management.modelmbean.RequiredModelMBean
at java.io.ObjectOutputStream.writeObject0(ObjectOutp utStream.java:1054)
at java.io.ObjectOutputStream.writeObject(ObjectOutpu tStream.java:278)
at weblogic.common.internal.ChunkedObjectOutputStream .writeObject(ChunkedObjectOutputStream.java:120)
at weblogic.rjvm.MsgAbbrevOutputStream.writeObject(Ms gAbbrevOutputStream.java:93)
at weblogic.rmi.internal.ObjectIO.writeObject(ObjectI O.java:36)
at weblogic.rjvm.BasicOutboundRequest.marshalArgs(Bas icOutboundRequest.java:82)
... 18 more
--------------- nested within: ------------------
weblogic.rmi.extensions.RemoteRuntimeException: Unexpected Exception - with nested exception:
[java.rmi.MarshalException: failed to marshal registerMBean(Ljava.lang.Object;Ljavax.management. ObjectName;); nested exception is:
java.io.NotSerializableException: javax.management.modelmbean.RequiredModelMBean]
at weblogic.management.internal.RemoteMBeanServerImpl _815_WLStub.registerMBean(Unknown Source)
at org.springframework.jmx.export.MBeanExporter.doReg ister(MBeanExporter.java:566)
at org.springframework.jmx.export.MBeanExporter.regis terSimpleBean(MBeanExporter.java:519)
at org.springframework.jmx.export.MBeanExporter.regis terBeanInstance(MBeanExporter.java:467)
at org.springframework.jmx.export.MBeanExporter.regis terBeanNameOrInstance(MBeanExporter.java:441)
at org.springframework.jmx.export.MBeanExporter.regis terBeans(MBeanExporter.java:368)
at org.springframework.jmx.export.MBeanExporter.after PropertiesSet(MBeanExporter.java:312)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1059)
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)
at com.deuba.multiplexer.StandaloneLauncher.main(Stan daloneLauncher.java:29)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main (AppMain.java:86)
My requirement is this. I have a simple bean.
I would like to be able to administer the bean at runtime.
I'd like to use JMX for this as it is standard.
My bean lives in a simple standalone application that has access to a remote WebLogic MBeanServer, so after some searching these forums I found the
WebLogicMBeanServerFactoryBean class which seems to fit the bill.
What I'd like to do is register the simple bean (I've put the simple bean on
weblogic server's classpath) with the weblogic server, and then use mc4j to
try and update it's properties at runtime.
I'm trying to register the simple bean with the following config:
<bean id="mbeanServer" class="org.springframework.jmx.support.WebLogicMBeanServe rFactoryBean">
<property name="serverName">
<value>george</value>
</property>
</bean>
<bean id="testBean" class="com.deuba.multiplexer.TestBean">
<property name="age">
<value>100</value>
</property>
<property name="name">
<value>Yoda</value>
</property>
</bean>
<bean id="exportedMBeanService" class="org.springframework.jmx.export.MBeanExporter">
<property name="beans">
<map>
<entry key="db:Name=TestBean" value-ref="testBean"/>
</map>
</property>
<property name="server" ref="mbeanServer"/>
</bean>
but I get an exception (in full below) caused by:
java.io.NotSerializableException: javax.management.modelmbean.RequiredModelMBean
which suggests I'm doing something very wrong. Is there a way to achieve this in Spring? I've managed to do this writing the MBeanServer lookup and
MBean registration myself but that's just too much work isn't it? :)
INFO org.springframework.beans.factory.xml.XmlBeanDefin itionReader 09:29:59,356 [main]: Loading XML bean definitions from class path resource [multiplexer-example.xml]
INFO org.springframework.core.CollectionFactory 09:29:59,543 [main]: JDK 1.4+ collections available
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'exportedMBeanService' defined in class path resource [multiplexer-example.xml]: Initialization of bean failed; nested exception is weblogic.rmi.extensions.RemoteRuntimeException: Unexpected Exception
java.rmi.MarshalException: failed to marshal registerMBean(Ljava.lang.Object;Ljavax.management. ObjectName;); nested exception is:
java.io.NotSerializableException: javax.management.modelmbean.RequiredModelMBean
at weblogic.rjvm.BasicOutboundRequest.marshalArgs(Bas icOutboundRequest.java:86)
at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicR emoteRef.java:163)
at weblogic.management.internal.RemoteMBeanServerImpl _815_WLStub.registerMBean(Unknown Source)
at org.springframework.jmx.export.MBeanExporter.doReg ister(MBeanExporter.java:566)
at org.springframework.jmx.export.MBeanExporter.regis terSimpleBean(MBeanExporter.java:519)
at org.springframework.jmx.export.MBeanExporter.regis terBeanInstance(MBeanExporter.java:467)
at org.springframework.jmx.export.MBeanExporter.regis terBeanNameOrInstance(MBeanExporter.java:441)
at org.springframework.jmx.export.MBeanExporter.regis terBeans(MBeanExporter.java:368)
at org.springframework.jmx.export.MBeanExporter.after PropertiesSet(MBeanExporter.java:312)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1059)
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)
at com.deuba.multiplexer.StandaloneLauncher.main(Stan daloneLauncher.java:29)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main (AppMain.java:86)
Caused by: java.io.NotSerializableException: javax.management.modelmbean.RequiredModelMBean
at java.io.ObjectOutputStream.writeObject0(ObjectOutp utStream.java:1054)
at java.io.ObjectOutputStream.writeObject(ObjectOutpu tStream.java:278)
at weblogic.common.internal.ChunkedObjectOutputStream .writeObject(ChunkedObjectOutputStream.java:120)
at weblogic.rjvm.MsgAbbrevOutputStream.writeObject(Ms gAbbrevOutputStream.java:93)
at weblogic.rmi.internal.ObjectIO.writeObject(ObjectI O.java:36)
at weblogic.rjvm.BasicOutboundRequest.marshalArgs(Bas icOutboundRequest.java:82)
... 18 more
--------------- nested within: ------------------
weblogic.rmi.extensions.RemoteRuntimeException: Unexpected Exception - with nested exception:
[java.rmi.MarshalException: failed to marshal registerMBean(Ljava.lang.Object;Ljavax.management. ObjectName;); nested exception is:
java.io.NotSerializableException: javax.management.modelmbean.RequiredModelMBean]
at weblogic.management.internal.RemoteMBeanServerImpl _815_WLStub.registerMBean(Unknown Source)
at org.springframework.jmx.export.MBeanExporter.doReg ister(MBeanExporter.java:566)
at org.springframework.jmx.export.MBeanExporter.regis terSimpleBean(MBeanExporter.java:519)
at org.springframework.jmx.export.MBeanExporter.regis terBeanInstance(MBeanExporter.java:467)
at org.springframework.jmx.export.MBeanExporter.regis terBeanNameOrInstance(MBeanExporter.java:441)
at org.springframework.jmx.export.MBeanExporter.regis terBeans(MBeanExporter.java:368)
at org.springframework.jmx.export.MBeanExporter.after PropertiesSet(MBeanExporter.java:312)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1059)
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)
at com.deuba.multiplexer.StandaloneLauncher.main(Stan daloneLauncher.java:29)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main (AppMain.java:86)