Results 1 to 5 of 5

Thread: Spring, JMX and RMI

  1. #1
    Join Date
    Jun 2007
    Posts
    2

    Default Spring, JMX and RMI

    For several month I use JMX in pure Java applications. Now we want to expand our spring applications with JMX too.
    For our example we use Tomcat 5.5, JDK 1.6 and Spring 2.0.2 .
    All seems to work since trying to initialize the rmi-connector :



    2007-06-19 13:19:14,706 [Thread-1] DEBUG org.springframework.jmx.support.JmxUtils - Found MBeanServer: com.sun.jmx.mbeanserver.JmxMBeanServer@5a3923
    2007-06-19 13:19:15,784 [Thread-1] INFO org.springframework.beans.factory.support.DefaultL istableBeanFactory - Destroying singletons in {org.springframework.beans.factory.support.Default ListableBeanFactory defining beans [camclient,localCollector,exporter,serverConnector, registry]; root of BeanFactory hierarchy}
    2007-06-19 13:19:15,799 [Thread-1] ERROR org.springframework.web.context.ContextLoader - Context initialization failed
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'exporter' defined in ServletContext resource [/WEB-INF/client.xml]: Cannot resolve reference to bean 'serverConnector' while setting bean property 'server'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'serverConnector' defined in ServletContext resource [/WEB-INF/client.xml]: Invocation of init method failed; nested exception is java.io.IOException: Cannot bind to URL [rmi://localhost:1099/camclient]: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
    java.net.ConnectException: Connection refused: connect]
    Caused by:
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'serverConnector' defined in ServletContext resource [/WEB-INF/client.xml]: Invocation of init method failed; nested exception is java.io.IOException: Cannot bind to URL [rmi://localhost:1099/camclient]: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
    java.net.ConnectException: Connection refused: connect]
    Caused by:
    java.io.IOException: Cannot bind to URL [rmi://localhost:1099/camclient]: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
    java.net.ConnectException: Connection refused: connect]
    at javax.management.remote.rmi.RMIConnectorServer.new IOException(Unknown Source)
    at javax.management.remote.rmi.RMIConnectorServer.sta rt(Unknown Source)
    at org.springframework.jmx.support.ConnectorServerFac toryBean.afterPropertiesSet(ConnectorServerFactory Bean.java:168)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1118)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1085)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:429)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 50)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:141)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:247)
    ...


    The configuration looks like :

    <?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="camclient" class="demo.spring.client.CamClient">
    ..
    </bean>

    <bean id="exporter" class="org.springframework.jmx.export.MBeanExporte r" lazy-init="false">
    <property name="beans">
    <map>
    <entry key="bean:name=camclient" value-ref="camclient"/>
    </map>
    </property>
    <property name="server" ref="serverConnector"/>
    </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:///jndi/rmi://localhost:1099/camclient"/>
    </bean>

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

    </beans>


    Any ideas whats going wrong?

    Thanks,

    Uwe

    PS : i am newbie in spring

  2. #2
    Join Date
    Sep 2004
    Location
    London, UK
    Posts
    64

    Default

    Add depends-on attribute for serverConnector bean:
    Code:
    <bean id="serverConnector" class="org.springframework.jmx.support.ConnectorSe rverFactoryBean" depends-on="registry">

  3. #3
    Join Date
    Jun 2007
    Posts
    2

    Default

    .. and it works - Thanks!

  4. #4
    Join Date
    Sep 2006
    Location
    zurich
    Posts
    11

    Default rmiregistry startup still too slow on windows

    Hi,

    I have pretty much the same setup in the config file and I get the same error even with the

    depends-on="registry"

    set in the serverConnector bean definition. It looks like the registry startup was too slow? If I manually start a rmiregistry before starting up tomcat, all works fine...

    regards raoul

  5. #5
    Join Date
    Mar 2012
    Posts
    3

    Default

    Thank you so much, the spring ref doc should really update to reflect this.

Posting Permissions

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