Announcement Announcement Module
Collapse
No announcement yet.
MBeanServerConnectionFactoryBean reconnect Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • MBeanServerConnectionFactoryBean reconnect

    We are trying to use MBeanServerConnectionFactoryBean in our application to make a JMX call to validate connectivity. If the server he is connected to goes down, we do not see anyway to force the bean to reconnect. Are we missing something?

    Thanks,
    David

  • #2
    Hey David

    I am having the same issue have you found anything about reconnecting?
    Any help appreciated.

    Thanks
    Paul

    Comment


    • #3
      Some Sample Code

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

      <bean id="smppJmxController" class="org.springframework.jmx.access.MBeanProxyFa ctoryBean">
      <property name="objectName" value="com.myname:name=MyClassJmxController"/>
      <property name="proxyInterface" value="MYCLASSNAME"/>
      <property name="server"><ref bean="jmxConnection"/></property>
      </bean>

      Now I can connect to the MYCLASSNAME however if for any reason the jmx server goes down and is then restarted or available again I cannot connect to it. It is a MVC webapp by the way the following is the error i get on the controller trying to use the mbean

      org.springframework.jmx.access.InvocationFailureEx ception: JMX access failed; nested exception is java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
      java.net.ConnectException: Connection refused

      I want ot be able to somehoe have the server reconnect so that my calls will be successful am I doing this totally wrong?

      Any pointers appreciated.

      Thanks
      Paul

      Comment


      • #4
        I am now trying to reconect by call refresh in the webapplicationContext but I get the following message.

        [org.springframework.beans.factory.support.Disposab leBeanAdapter] - Couldn't invoke destroy method of bean with name 'jmxConnection'
        java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:

        Needless to say I am not getting anywhere fast with this issue please help

        Comment


        • #5
          MBeanServerConnectionFactoryBean reconnect

          We subclassed the Spring class and put the reconnect in ourselves.

          David

          Comment


          • #6
            Thanks David

            Comment


            • #7
              Originally posted by davidr View Post
              We subclassed the Spring class and put the reconnect in ourselves.
              Would you be willing to share? This would be a fantastically useful feature for me.

              Comment


              • #8
                We did it but without spring

                Code attached

                Comment


                • #9
                  Could someone tell me if this code really works? Seems like some nub (like me) first shot.

                  Comment


                  • #10
                    I didn't use it. Instead, I rely on Spring to handle the server-based JMX connector, but use a custom, non-Spring client that connects for each method invocation.

                    Comment


                    • #11
                      Code:
                      <bean id="connector"   
                      class="org.springframework.jmx.support.MBeanServerConnectionFactoryBean"
                              lazy-init="true" scope="prototype">
                              <property name="serviceUrl"
                                  value="service:jmx:rmi://..."/>
                          </bean>
                      
                          <bean id="control"
                              class="org.springframework.jmx.access.MBeanProxyFactoryBean"
                              lazy-init="true" scope="prototype">
                              <property name="objectName" value="..." />
                              <property name="proxyInterface"
                                  value="a.b.c.Control" />
                              <property name="server" ref="connector" />
                              <property name="connectOnStartup" value="false" />
                          </bean>
                      
                          <!-- 
                                  use the factory to lookup the control, 
                                  in case the jmx server restarts 
                           -->
                          <bean id="controlFactory"      
                      class="org.springframework.beans.factory.config.ObjectFactoryCreatingFactoryBean">
                              <property name="targetBeanName">
                                  <idref local="control" />
                              </property>
                          </bean>

                      Comment


                      • #12
                        I know this thread is a little old, but I was facing the same problem and found a solution without having to write my own code.

                        I'm using Spring 3.0.5.RELEASE

                        Code:
                           <bean id="myMonitor" class="org.springframework.jmx.access.MBeanProxyFactoryBean" lazy-init="true">
                                <property name="objectName" value="etl:name=..."/>
                                <property name="proxyInterface" value="..."/>
                                <property name="serviceUrl" value="service:jmx:rmi://localhost/jndi/rmi://localhost:1099/jmxrmi"/>
                                <property name="refreshOnConnectFailure" value="true" />
                            </bean>
                        You can't use this method of refreshOnConnectFailure with MBeanServerConnectionFactoryBean it only works if you specify serviceUrl directly on your MBeanProxyFactoryBean.

                        Comment


                        • #13
                          Well the original post was very old so maybe there was no solution for the problem back than but I posted a solution with current Spring version that worked great for me.

                          Have you tried it? If you're having specific problems, maybe I can help.
                          Just provide more details.

                          Comment


                          • #14
                            My business is now attempting to reconect by call refresh from the webapplicationContext but I purchase the next message.

                            [org.springframework.beans.factory.support.Disposab leBeanAdapter] - Couldn't invoke destroy means of bean with name 'jmxConnection'
                            java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:

                            Needless to say I am not saying getting anywhere fast using this type of issue please help

                            Comment

                            Working...
                            X