Announcement Announcement Module
Collapse
No announcement yet.
Exception registering simple bean with WebLogicMBeanServerFactoryBean Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Exception registering simple bean with WebLogicMBeanServerFactoryBean

    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:

    Code:
    <bean id="mbeanServer" class="org.springframework.jmx.support.WebLogicMBeanServerFactoryBean">
            <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:

    Code:
    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?

    Code:
    INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader 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.BeanCreationException: 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(BasicOutboundRequest.java:86)
    	at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:163)
    	at weblogic.management.internal.RemoteMBeanServerImpl_815_WLStub.registerMBean(Unknown Source)
    	at org.springframework.jmx.export.MBeanExporter.doRegister(MBeanExporter.java:566)
    	at org.springframework.jmx.export.MBeanExporter.registerSimpleBean(MBeanExporter.java:519)
    	at org.springframework.jmx.export.MBeanExporter.registerBeanInstance(MBeanExporter.java:467)
    	at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:441)
    	at org.springframework.jmx.export.MBeanExporter.registerBeans(MBeanExporter.java:368)
    	at org.springframework.jmx.export.MBeanExporter.afterPropertiesSet(MBeanExporter.java:312)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1059)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:363)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
    	at com.deuba.multiplexer.StandaloneLauncher.main(StandaloneLauncher.java:29)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.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(ObjectOutputStream.java:1054)
    	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
    	at weblogic.common.internal.ChunkedObjectOutputStream.writeObject(ChunkedObjectOutputStream.java:120)
    	at weblogic.rjvm.MsgAbbrevOutputStream.writeObject(MsgAbbrevOutputStream.java:93)
    	at weblogic.rmi.internal.ObjectIO.writeObject(ObjectIO.java:36)
    	at weblogic.rjvm.BasicOutboundRequest.marshalArgs(BasicOutboundRequest.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.doRegister(MBeanExporter.java:566)
    	at org.springframework.jmx.export.MBeanExporter.registerSimpleBean(MBeanExporter.java:519)
    	at org.springframework.jmx.export.MBeanExporter.registerBeanInstance(MBeanExporter.java:467)
    	at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:441)
    	at org.springframework.jmx.export.MBeanExporter.registerBeans(MBeanExporter.java:368)
    	at org.springframework.jmx.export.MBeanExporter.afterPropertiesSet(MBeanExporter.java:312)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1059)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:363)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
    	at com.deuba.multiplexer.StandaloneLauncher.main(StandaloneLauncher.java:29)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:324)
    	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:86)

  • #2
    Problem solved

    Maybe I shouldn't have tried registering my beans outside of the VM that runs the container... It's not a particularly realistic scenario.

    I just ran up the 1.5 jre and got it working in a jiffy...

    It turned out to be a very simple way to test Spring JMX. I used 1.5 jre and mc4j to check my mbeans got registered.

    Comment

    Working...
    X