Announcement Announcement Module
Collapse
No announcement yet.
How to solve InvalidInvocationException Exception? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to solve InvalidInvocationException Exception?

    Firstly, Post my spring config xml.
    server:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

    <beans>

    <bean id="serverConnector" depends-on="registry"
    class="org.springframework.jmx.support.ConnectorSe rverFactoryBean">
    <property name="objectName" value="connector:name=rmi" />
    <property name="serviceUrl" value="service:jmx:rmi:///jndi/rmi://localhost:9875/123456" />
    </bean>

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

    <bean id="mbeanserver" class="org.springframework.jmx.support.MBeanServer FactoryBean">
    <!-- property name="defaultDomain" value="JMI:type=MBean1111111111Server" /-->
    <!-- indicate to first look for a server -->
    <property name="locateExistingServerIfPossible" value="false"/>
    <!-- property name="agentId" value="MBeanTest"/-->
    </bean>

    <bean id="jmxMBeanExport" class="org.springframework.jmx.export.MBeanExporte r">
    <property name="server" ref="mbeanserver" />

    <property name="beans">
    <map>
    <entry key="bean:name=boy">
    <bean class="com.ebupt.jmxTest.boy">
    </bean>
    </entry>

    <entry key="bean:name=dog">
    <bean class="com.ebupt.jmxTest.dog" />
    </entry>
    </map>
    </property>

    <property name="assembler">
    <bean
    class="org.springframework.jmx.export.assembler.In terfaceBasedMBeanInfoAssembler">
    <property name="interfaceMappings">
    <props>
    <prop key="bean:name=boy">
    com.ebupt.jmxTest.Man
    </prop>

    <prop key="bean:name=dog">
    com.ebupt.jmxTest.Animal
    </prop>

    </props>
    </property>
    </bean>
    </property>

    </bean>

    </beans>
    client:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

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

    <bean id="proxy"
    class="org.springframework.jmx.access.MBeanProxyFa ctoryBean">
    <property name="objectName" value="bean:name=boy"/>
    <property name="server">
    <ref local="clientConnector"/>
    </property>
    <property name="proxyInterface" value="com.ebupt.jmxTest.Man"/>
    </bean>

    </beans>
    As I know, In bean mbeanserver there is a property named locateExistingServerIfPossible that indicates whether to first look for a server and its default value is false.
    currntly, when locateExistingServerIfPossible is set to false, JVM will throw InvalidInvocationException.
    Exception in thread "main" org.springframework.jmx.access.InvalidInvocationEx ception: bean:name=boy
    at org.springframework.jmx.access.MBeanClientIntercep tor.invoke(MBeanClientInterceptor.java:358)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:204)
    at $Proxy0.sayHello(Unknown Source)
    at com.ebupt.jmxTest.Client.main(Client.java:13)

    conversely, JVM runs smoothly if locateExistingServerIfPossible is set to true.
    I don't know the reason why JVM throws InvalidInvocationException if locateExistingServerIfPossible is set to false and it runns well if true. and How to solve this problem if I set locateExistingServerIfPossible to false.
    Thx. source is found in enclosure

  • #2
    Proxy on Interface

    The framework can not find by reflection a means to invoke an ObjectInstance from your mbean perhaps after checking to see if the class is abstract or interface, this exception is thrown.

    So for example I resolved this by passing in interfaces (mbean.class)
    Code:
    return (T) MBeanServerInvocationHandler.newProxyInstance(connection, objectName, mbean, true);
    I hope that helps

    Comment

    Working...
    X