Results 1 to 6 of 6

Thread: how to configuring a remote client proxy

Hybrid View

  1. #1
    Join Date
    Nov 2005
    Posts
    2

    Smile how to configuring a remote client proxy

    A little assistance with defining a remote client proxy would be appreciated. if there is a small but complete example app using mbeanserverconnectionfactorybean, and proxying JMX MBeans would be very helpful.

    This is what I have so far:

    in my applicationContext.xml i have the following defined.

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

    <bean id="runtime" class="org.springframework.jmx.access.MBeanProxyFa ctoryBean">
    <property name="objectName" value="java.lang:type=Runtime"/>
    <property name=roxyInterface" value="springJMX.RunTimeInfo"/>
    </bean>
    </beans>

    THere is an RunTimeInfo Java interface that has 4 getters including getVmInfo as an example.

    There is a main Java class that successully establishes an MBeanServerConnection instance called clientConnector which succesfully retrieves the domains from Tomcat, so I know that part is correct.

    I do not refererence in the main app the RunTimeInfo interface.

    The error I am getting when I run the app is: Exception in thread "main" org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'runtime' defined in class path resource [applicationContext.xml]: Initialization of bean failed;nested exception is org.springframewor.jmx.MBeanServerNotFoundExceptio n: Unable to locate MBeanServer instance.

    I am not sure what is missing since I know I received my remote MBean Server instance from Spring. My Main app contains the following:

    MBeanServerConnection clientConnnector = (MBeanServerConnection) ctx.getBean("clientConnector");


    Any suggestions or a Java code and xml example of proxying remote JMX beans would be great. Thank you.

    - Andy

  2. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Can you post the full stacktrace? The error seems to be thrown because the JMX server is not located. Have you looked at the samples and documentation from the main Spring distribution?
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  3. #3
    Join Date
    Jun 2006
    Posts
    18

    Default

    I get a similar issue - seems to be related to needing security properties set? - see stack trace below:

    Code:
    og4j:WARN Please initialize the log4j system properly.
    java.io.FileNotFoundException: C:\rubicon-svn\DEV\modules\common\vendor_lib\config\security.properties (The system cannot find the path specified)
    	at java.io.FileInputStream.open(Native Method)
    	at java.io.FileInputStream.<init>(FileInputStream.java:106)
    	at com.sun.enterprise.util.Utility.getPropertiesFromFile(Utility.java:42)
    	at com.sun.enterprise.iiop.POAEJBORB.<clinit>(POAEJBORB.java:78)
    	at java.lang.Class.forName0(Native Method)
    	at java.lang.Class.forName(Class.java:242)
    	at org.omg.CORBA.ORB.create_impl(ORB.java:295)
    	at org.omg.CORBA.ORB.init(ORB.java:336)
    	at com.sun.enterprise.util.ORBManager.createORB(ORBManager.java:138)
    	at com.sun.enterprise.util.ORBManager.init(ORBManager.java:65)
    	at com.sun.enterprise.naming.SerialInitContextFactory.<init>(SerialInitContextFactory.java:31)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    	at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
    	at java.lang.Class.newInstance0(Class.java:350)
    	at java.lang.Class.newInstance(Class.java:303)
    	at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)
    	at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
    	at javax.naming.InitialContext.init(InitialContext.java:223)
    	at javax.naming.InitialContext.<init>(InitialContext.java:197)
    	at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1815)
    	at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1787)
    	at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:259)
    	at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248)
    	at org.springframework.jmx.support.MBeanServerConnectionFactoryBean.connect(MBeanServerConnectionFactoryBean.java:117)
    	at org.springframework.jmx.support.MBeanServerConnectionFactoryBean.afterPropertiesSet(MBeanServerConnectionFactoryBean.java:105)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1091)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:396)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:233)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:145)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:277)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:313)
    	at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:89)
    	at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:74)
    	at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:65)
    	at com.rubicon.feed.management.gui.ServiceControllerFrame.main(ServiceControllerFrame.java:139)
    java.io.FileNotFoundException: C:\rubicon-svn\DEV\modules\common\vendor_lib\config\ejb.properties (The system cannot find the path specified)
    	at java.io.FileInputStream.open(Native Method)
    	at java.io.FileInputStream.<init>(FileInputStream.java:106)
    	at com.sun.enterprise.util.Utility.getPropertiesFromFile(Utility.java:42)
    	at com.sun.enterprise.iiop.J2EEInitializer.<init>(J2EEInitializer.java:54)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    	at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
    	at java.lang.Class.newInstance0(Class.java:350)
    	at java.lang.Class.newInstance(Class.java:303)
    	at com.sun.corba.ee.internal.Interceptors.PIORB.registerORBInitializers(PIORB.java:377)
    	at com.sun.corba.ee.internal.Interceptors.PIORB.parseProperties(PIORB.java:347)
    	at com.sun.corba.ee.internal.TxPOA.TxPIORB.parseProperties(TxPIORB.java:116)
    	at com.sun.corba.ee.internal.corba.ORB.set_parameters(ORB.java:461)
    	at com.sun.corba.ee.internal.POA.POAORB.set_parameters(POAORB.java:156)
    	at com.sun.corba.ee.internal.Interceptors.PIORB.set_parameters(PIORB.java:336)
    	at org.omg.CORBA.ORB.init(ORB.java:337)
    	at com.sun.enterprise.util.ORBManager.createORB(ORBManager.java:138)
    	at com.sun.enterprise.util.ORBManager.init(ORBManager.java:65)
    	at com.sun.enterprise.naming.SerialInitContextFactory.<init>(SerialInitContextFactory.java:31)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    	at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
    	at java.lang.Class.newInstance0(Class.java:350)
    	at java.lang.Class.newInstance(Class.java:303)
    	at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)
    	at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
    	at javax.naming.InitialContext.init(InitialContext.java:223)
    	at javax.naming.InitialContext.<init>(InitialContext.java:197)
    	at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1815)
    	at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1787)
    	at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:259)
    	at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248)
    	at org.springframework.jmx.support.MBeanServerConnectionFactoryBean.connect(MBeanServerConnectionFactoryBean.java:117)
    	at org.springframework.jmx.support.MBeanServerConnectionFactoryBean.afterPropertiesSet(MBeanServerConnectionFactoryBean.java:105)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1091)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:396)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:233)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:145)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:277)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:313)
    	at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:89)
    	at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:74)
    	at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:65)
    	at com.rubicon.feed.management.gui.ServiceControllerFrame.main(ServiceControllerFrame.java:139)
    
    Warning: unable to read transaction.interoperability config property
    Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'feedManager' defined in file [C:\rubicon-svn\DEV\runtime\superd\config\SCApplicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.jmx.MBeanServerNotFoundException: Unable to locate an MBeanServer instance
    org.springframework.jmx.MBeanServerNotFoundException: Unable to locate an MBeanServer instance
    	at org.springframework.jmx.support.JmxUtils.locateMBeanServer(JmxUtils.java:85)
    	at org.springframework.jmx.support.JmxUtils.locateMBeanServer(JmxUtils.java:67)
    	at org.springframework.jmx.access.MBeanClientInterceptor.connect(MBeanClientInterceptor.java:211)
    	at org.springframework.jmx.access.MBeanClientInterceptor.afterPropertiesSet(MBeanClientInterceptor.java:184)
    	at org.springframework.jmx.access.MBeanProxyFactoryBean.afterPropertiesSet(MBeanProxyFactoryBean.java:69)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1091)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:396)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:233)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:145)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:277)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:313)
    	at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:89)
    	at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:74)
    	at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:65)
    	at com.rubicon.feed.management.gui.ServiceControllerFrame.main(ServiceControllerFrame.java:139)

  4. #4
    Join Date
    Jun 2006
    Posts
    18

    Default

    that may be a red herring. If I place empty files in the locatiosn referenced then the first two parts of the trace disappear and it simply complains about not being able to find the mbean server.

  5. #5
    Join Date
    Jun 2006
    Posts
    18

    Default

    All I'm really trying to do is programmatically access beans which previously I was using the jmx console to view and manipulate. Is there a good place to find sample client code? The reference documents seem to focus on the server side with very little about client connections.

  6. #6
    Join Date
    Jun 2006
    Posts
    18

    Default

    more careful reading of the doco! The "server" property is all important

    Code:
    <bean id="clientConnector"
          class="org.springframework.jmx.support.MBeanServerConnectionFactoryBean">
      <property name="serviceUrl" value="service:jmx:rmi://remotehost:9875"/>
    </bean>
    
    <bean id="proxy" class="org.springframework.jmx.access.MBeanProxyFactoryBean">
      <property name="objectName" value="bean:name=testBean"/>
      <property name="proxyInterface" value="org.springframework.jmx.IJmxTestBean"/>
      <property name="server" ref="clientConnector"/>
    </bean>

Posting Permissions

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