MBean's JNDI attribute times out at JBoss startup but works
pisce Feb 26, 2009 11:03 AMHello,
I'm facing a curious problem, trying to expose Hibernate's statistics through JMX. I updated jboss-service.xml to add the following:
<mbean code="org.hibernate.jmx.StatisticsService" name="jboss.monitoring:service=StatisticsService,name=xxxStatisticsService"> <attribute name="StatisticsEnabled">true</attribute> <attribute name="SessionFactoryJNDIName">persistence.units:ear=xxx.ear,jar=xxx.jar,unitName=xxx_pu</attribute> </mbean>
When JBoss AS starts, I receive the following error:
16:36:46,532 INFO [Server] Core system initialized 16:36:53,188 ERROR [StatisticsService] Error while accessing session factory with JNDI name persistence.units:ear=xxx.ear,jar=xxx.jar,unitName=xxx_pu javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1465) at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1594) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:634) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627) at javax.naming.InitialContext.lookup(InitialContext.java:351) at org.hibernate.jmx.StatisticsService.setSessionFactoryJNDIName(StatisticsService.java:67) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.jboss.mx.interceptor.AttributeDispatcher.invoke(AttributeDispatcher.java:136) at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) at org.jboss.mx.server.Invocation.invoke(Invocation.java:86) at org.jboss.mx.interceptor.ModelMBeanAttributeInterceptor.invoke(ModelMBeanAttributeInterceptor.java:103) at org.jboss.mx.interceptor.PersistenceInterceptor.invoke(PersistenceInterceptor.java:76) at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) at org.jboss.mx.server.AbstractMBeanInvoker.setAttribute(AbstractMBeanInvoker.java:461) at org.jboss.mx.server.MBeanServerImpl.setAttribute(MBeanServerImpl.java:608) at org.jboss.system.ServiceConfigurator.setAttribute(ServiceConfigurator.java:703) at org.jboss.system.ServiceConfigurator.configure(ServiceConfigurator.java:332) at org.jboss.system.ServiceConfigurator.internalInstall(ServiceConfigurator.java:462) at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java:171) at org.jboss.system.ServiceController.install(ServiceController.java:226) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155) at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) at org.jboss.mx.server.Invocation.invoke(Invocation.java:86) at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210) at $Proxy4.install(Unknown Source) at org.jboss.deployment.SARDeployer.create(SARDeployer.java:249) at org.jboss.deployment.MainDeployer.create(MainDeployer.java:969) at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:818) at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782) at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:766) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155) at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133) at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142) at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210) at $Proxy5.deploy(Unknown Source) at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482) at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362) at org.jboss.Main.boot(Main.java:200) at org.jboss.Main$1.run(Main.java:508) at java.lang.Thread.run(Thread.java:595) Caused by: java.net.SocketTimeoutException: Receive timed out at java.net.PlainDatagramSocketImpl.receive0(Native Method) at java.net.PlainDatagramSocketImpl.receive(PlainDatagramSocketImpl.java:136) at java.net.DatagramSocket.receive(DatagramSocket.java:712) at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1435) ... 57 more
Please note that this occur every time for this JNDI attribute, but not if I set a simple value (i.e. a plain string with no special char).
However, once the server is started, I can access my MBean through the JMX console, set the SessionFactoryJNDIName attribute with the same value, and then see updated Hibernate statistics as I first expected. I double-checked this value, which seems to be the real JNDI name for my Hibernate SessionFactory.
I guess this is a JBoss AS issue, but how can I solve this, or work around this?