Results 1 to 2 of 2

Thread: Problem with injecting MBeanServerConnectionFactoryBean

  1. #1

    Default Problem with injecting MBeanServerConnectionFactoryBean

    Env: JDK1.6, Spring 2.5.1

    I have an MBean server and am enabling remoting using RMI.
    I am defining an MBeanServerConnectionFactoryBean with the
    service URL to enable clients to connect:

    Code:
    <bean
              id="jmxClientInterface"
             class="org.springframework.jmx.support.MBeanServerConnectionFactoryBean"
    
                p:serviceUrl="${my.serviceurl}"
                p:connectOnStartup="false"
         />
    I inject this factory bean into a typical client as follows:

    Code:
      package com.xxx.client;
    
      public class JmxClient {
        //...
    private MBeanServerConnectionFactoryBean connection_factory;
    	public MBeanServerConnectionFactoryBean getServerConnectionFactory() {
    		return connection_factory;
    	}
    	public synchronized final void setServerConnectionFactory(final MBeanServerConnectionFactoryBean x) {
    		this.connection_factory = x;
    	}
    
         //...
     }
    
         <bean 
           id="jmxClient"
           class="com.xxx.client.JmxClient"
           scope="prototype"
             
             p:serverConnectionFactory-ref="jmxClientInterface"
             p:defaultDomain="${my.domain}"
        />
    The problem: however this injection yields an exception as follows.
    I am injecting an MBeanServerConnectionFactoryBean into a field
    which is of the same type (MBeanServerConnectionFactoryBean).
    Yet, it says that the injected entity is of type $Proxy.

    Code:
    PropertyAccessException 1: 
         org.springframework.beans.TypeMismatchException: 
              Failed to convert property value of type [$Proxy19] to required type 
              [org.springframework.jmx.support.MBeanServerConnectionFactoryBean] 
           for property 'serverConnectionFactory'; 
            nested exception is java.lang.IllegalArgumentException: 
             Cannot convert value of type [$Proxy19] to required type 
          [org.springframework.jmx.support.MBeanServerConnectionFactoryBean] 
              for property 'serverConnectionFactory': 
               no matching editors or conversion strategy found
    What am I missing? How did the injected MBeanServerConnectionFactoryBean
    suddenly become a proxy?

    Thanks,

    /U

  2. #2
    Join Date
    Sep 2007
    Location
    Oceanside, CA
    Posts
    187

    Default

    Are you trying to inject the MBeanServerConnectionFactoryBean into your JmxClient bean, or the MBeanServerConnection it produces? Currently, it looks like your configuration will inject the MBeanServerConnection produced by the MBeanServerConnectionFactoryBean, which will be a proxy that lazily creates the connection.

    If you want to inject the FactoryBean itself, you can do something like this:

    Code:
         <bean 
           id="jmxClient"
           class="com.xxx.client.JmxClient"
           scope="prototype"  
           p:serverConnectionFactory-ref="&amp;jmxClientInterface"
           p:defaultDomain="${my.domain}"
        />
    See here for more details:

    http://static.springframework.org/sp...on-factorybean
    Mike Bingham

Posting Permissions

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