Results 1 to 2 of 2

Thread: JMX remote MBean invocation via RMI

Threaded View

  1. #1

    Default JMX remote MBean invocation via RMI

    Hi at all,

    I have the necessity to invoke ancd manipulate an MBean remotely through rmi protocol.

    I have build a simple resource taht was been instrumented using spring MBeanExporter. To the server side all is correct, I hope.

    This is the bean factory xml file :

    <beans>
    <bean id="component"
    class="jmx.study.springsupport.resource.Component" singleton="false">
    <property name="name" value="samuele" />
    <property name="age" value="10" />
    </bean>

    <bean id="mbeanServer"
    class="org.springframework.jmx.support.MBeanServer FactoryBean"/>

    <bean id="exporter" class="org.springframework.jmx.export.MBeanExporte r" lazy-init="false">
    <property name="beans">
    <map>
    <entry key="bean:name=component" value-ref="component"/>
    </map>
    </property>
    <property name="server" ref="mbeanServer"/>
    </bean>


    <bean id="registry" class="org.springframework.remoting.rmi.RmiRegistr yFactoryBean">
    <property name="port" value="1099"/>
    </bean>

    <bean id="serverConnector" class="org.springframework.jmx.support.ConnectorSe rverFactoryBean">
    <property name="objectName" value="connector:name=rmi"/>
    <property name="serviceUrl" value="service:jmx:rmi://localhost/jndi/rmi://localhost:1099/myconnector"/>
    </bean>

    </beans>

    On the client side I have write a simple class, and this is the factory configuration file:

    <beans>

    <bean id="clientConnector" class="org.springframework.jmx.support.MBeanServer ConnectionFactoryBean">
    <property name="serviceUrl" value="service:jmx:rmi:///jndi/rmi://localhost:1099/myconnector"/>
    </bean>

    <bean id="proxy" class="org.springframework.jmx.access.MBeanProxyFa ctoryBean">
    <property name="objectName" value="bean:name=component"/>
    <property name="proxyInterface" value="jmx.study.springsupport.resource.ComponentI nterface"/>
    <property name="server" ref="clientConnector"/>
    </bean>
    </beans>

    The problem is:

    From the client side I can see the MBeanInfo object, and so all the information about the remote resource to manage.
    But I can't to invoke any method on this resource, because I can't instantiate iit.

    someone of us can show me, how I can instantiate a remote MBean, and then invoke on it a method to manage ?


    in client side code I access to the MBean in this mode:


    MBeanServerConnection connection = ((MBeanServerConnection) connectionFactory);
    System.out.println("Connection: "+connection);

    try {

    ObjectName mbeanName = new ObjectName("bean:name=component");
    MBeanInfo mbeanInfo = connection.getMBeanInfo(mbeanName);

    System.out.println("MBeanInfo : "+mbeanInfo.getClassName());

    connection.createMBean(mbeanInfo.getClassName(), mbeanName);



    } catch (InstanceNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (IntrospectionException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (MalformedObjectNameException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (ReflectionException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (NullPointerException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (InstanceAlreadyExistsException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (MBeanRegistrationException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (NotCompliantMBeanException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (MBeanException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }


    When the createMBean operation is executed I receive this exception:

    MBean class jmx.study.springsupport.resource.Component does not implement DynamicMBean, neither follows the Standard MBean conventions (javax.management.NotCompliantMBeanException: Class jmx.study.springsupport.resource.Component is not a JMX compliant Standard MBean) nor the MXBean conventions (javax.management.NotCompliantMBeanException: jmx.study.springsupport.resource.Component: Class jmx.study.springsupport.resource.Component is not a JMX compliant MXBean)
    at com.sun.jmx.mbeanserver.Introspector.checkComplian ce(Introspector.java:160)
    at com.sun.jmx.interceptor.DefaultMBeanServerIntercep tor.createMBean(DefaultMBeanServerInterceptor.java :287)
    at com.sun.jmx.interceptor.DefaultMBeanServerIntercep tor.createMBean(DefaultMBeanServerInterceptor.java :199)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.createMBean (JmxMBeanServer.java:286)
    at javax.management.remote.rmi.RMIConnectionImpl.doOp eration(RMIConnectionImpl.java:1381)
    at javax.management.remote.rmi.RMIConnectionImpl.acce ss$200(RMIConnectionImpl.java:72)
    at javax.management.remote.rmi.RMIConnectionImpl$Priv ilegedOperation.run(RMIConnectionImpl.java:1264)
    at javax.management.remote.rmi.RMIConnectionImpl.doPr ivilegedOperation(RMIConnectionImpl.java:1359)
    at javax.management.remote.rmi.RMIConnectionImpl.crea teMBean(RMIConnectionImpl.java:222)
    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:597)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastSe rverRef.java:305)
    at sun.rmi.transport.Transport$1.run(Transport.java:1 59)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport. java:155)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages( TCPTransport.java:535)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandl er.run0(TCPTransport.java:790)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandl er.run(TCPTransport.java:649)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run Task(ThreadPoolExecutor.java:885)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:907)
    at java.lang.Thread.run(Thread.java:619)
    at sun.rmi.transport.StreamRemoteCall.exceptionReceiv edFromServer(StreamRemoteCall.java:255)
    at sun.rmi.transport.StreamRemoteCall.executeCall(Str eamRemoteCall.java:233)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:1 42)
    at com.sun.jmx.remote.internal.PRef.invoke(Unknown Source)
    at javax.management.remote.rmi.RMIConnectionImpl_Stub .createMBean(Unknown Source)
    at javax.management.remote.rmi.RMIConnector$RemoteMBe anServerConnection.createMBean(RMIConnector.java:6 12)
    at jmx.study.springsupport.resource.ClientRemote.main (ClientRemote.java:46)



    Thanks a lot for yours suggestion.

    Samuele
    Last edited by samuele.pretini; May 12th, 2008 at 07:10 AM. Reason: Addind some particular

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •