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

  • MBeanProxyFactoryBean and connectOnStartup

    Hi, I am trying to use a MBeanProxyFactoryBean together with a clientConnector and the connectOnStartup = "false" option. Our scenario is the following. We have one web application exposing some MBeans via JMX (RMI). Another web application is invoking these MBeans via the MBeanProxyFactoryBean.

    During local development we use the maven-jetty-plugin to test the second web application. I don't want to see an Exception on startup if the first web application is not running. Here is the Spring configuration i am trying:

    PHP Code:
        <bean id="clientConnector" class="org.springframework.jmx.support.MBeanServerConnectionFactoryBean">
            <
    property name="serviceUrl" value="${web.remote.jmx.service.url}"/>
            <
    property name="connectOnStartup" value="false" />
        </
    bean>

        <
    bean id="gameplayRecordable" class="org.springframework.jmx.access.MBeanProxyFactoryBean">
            <
    property name="objectName" value="MYBEAN:name=GAMEPLAY_RECORDING" />
            <
    property name="proxyInterface" value="com.foo.protoconv.GameplayRecordable" />
            <
    property name="server" ref="clientConnector" />
            <
    property name="connectOnStartup" value="false" />
        </
    bean>

        <
    bean id="mFileReader" class="com.foo.protoconv.util.mfiles.MFileReader">
            <
    constructor-arg ref="gameplayRecordable"/>
        </
    bean
    Still I am getting an exception on startup (Stacktrace below) and I think this is not happening when the bean is used for the first time but on initialization:

    PHP Code:
    2011-08-23 17:14:14.990:WARN::Nested in org.springframework.beans.factory.BeanCreationExceptionError creating bean with name 'mFileReader' defined in class path resource [fileBeans.xml]: Instantiation of bean failednested exception is org.springframework.beans.BeanInstantiationExceptionCould not instantiate bean class [com.foo.protoconv.util.mfiles.MFileReader]: Constructor threw exceptionnested exception is org.springframework.jmx.access.MBeanConnectFailureExceptionI/O failure during JMX accessnested exception is java.io.IOExceptionFailed to retrieve RMIServer stubjavax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectExceptionConnection refused to hostlocalhostnested exception is: |?java.net.ConnectExceptionConnection refused]:
    java.net.ConnectExceptionConnection refused
        at java
    .net.PlainSocketImpl.socketConnect(Native Method)
        
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
        
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
        
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
        
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
        
    at java.net.Socket.connect(Socket.java:529)
        
    at java.net.Socket.connect(Socket.java:478)
        
    at java.net.Socket.<init>(Socket.java:375)
        
    at java.net.Socket.<init>(Socket.java:189)
        
    at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
        
    at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
        
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595)
        
    at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
        
    at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
        
    at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322)
        
    at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
        
    at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:97)
        
    at com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:185)
        
    at javax.naming.InitialContext.lookup(InitialContext.java:392)
        
    at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1888)
        
    at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1858)
        
    at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:257)
        
    at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248)
        
    at org.springframework.jmx.support.MBeanServerConnectionFactoryBean$JMXConnectorLazyInitTargetSource.createObject(MBeanServerConnectionFactoryBean.java:182)
        
    at org.springframework.aop.target.AbstractLazyCreationTargetSource.getTarget(AbstractLazyCreationTargetSource.java:83)
        
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:182)
        
    at $Proxy6.getMBeanServerConnection(Unknown Source)
        
    at org.springframework.jmx.support.MBeanServerConnectionFactoryBean$MBeanServerConnectionLazyInitTargetSource.createObject(MBeanServerConnectionFactoryBean.java:199)
        
    at org.springframework.aop.target.AbstractLazyCreationTargetSource.getTarget(AbstractLazyCreationTargetSource.java:83)
        
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:182)
        
    at $Proxy7.invoke(Unknown Source)
        
    at javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:288)
        
    at org.springframework.jmx.access.MBeanClientInterceptor.doInvoke(MBeanClientInterceptor.java:405)
        
    at org.springframework.jmx.access.MBeanClientInterceptor.invoke(MBeanClientInterceptor.java:353)
        
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
        
    at $Proxy8.recordDirectory(Unknown Source)
        
    at com.foo.protoconv.util.mfiles.MFileReader.<init>(MFileReader.java:43)
        
    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:513)
        
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)
        
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:108)
        
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:280)
        
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1003)
        
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:907)
        
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
        
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
        
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
        
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
        
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
        
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
        
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
        
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
        
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
        
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
        
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
        
    at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:549)
        
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
        
    at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1282)
        
    at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:518)
        
    at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:499)
        
    at org.mortbay.jetty.plugin.Jetty6PluginWebAppContext.doStart(Jetty6PluginWebAppContext.java:115)
        
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
        
    at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
        
    at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156)
        
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
        
    at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
        
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
        
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
        
    at org.mortbay.jetty.Server.doStart(Server.java:224)
        
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
        
    at org.mortbay.jetty.plugin.Jetty6PluginServer.start(Jetty6PluginServer.java:132)
        
    at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:454)
        
    at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:396)
        
    at  .. 
Working...
X