2 Replies Latest reply on Jan 8, 2009 10:53 AM by blep

    Timer problem when using jconsole

    andrea formica Newbie

      I had a weird problem in deploying my application under JBOSS-4.0.5, caused
      by a failure in finding an instance of Timer.

      Here is an overview of what I was doing:
      1) my application contains an MBean in which I inject a dependency on Timer using the following code:

       private static final String TIMER_SERVICE_NAME = "DefaultDomain:service=timer";
      
       private static final long TIME_GRANULARITY = Timer.ONE_MINUTE;
      
       private final MBeanServer server = MBeanServerLocator.locateJBoss();
      
       /**
       * need to put timer-service.xml in the deploy directory to make it work
       *
       * @uml.associationEnd
       */
       @Depends(TIMER_SERVICE_NAME)
       private TimerMBean timer;
      
       @Depends(TIMER_SERVICE_NAME)
       private ObjectName timerName;
      
      

      2) later on in the application I add to server some Notifications in order to call another function of the MBean
      when I receive a Notification from the Timer

      3) I deploy also a timer-service.xml in JBoss:

      <server>
      
       <!-- ==================================================================== -->
       <!-- JMX Timer MBean -->
       <!-- ==================================================================== -->
      
       <mbean code="javax.management.timer.Timer" name="DefaultDomain:service=timer"/>
      
      </server>
      
      


      Now, the code was working, and I was able to see from the jmx-console my MBean

      Then I decided I want to use jconsole from Sun java distribution, so I read some wiki pages in JBoss
      web site, and I added to $JBOSS_HOME/bin/run.conf the following line:

      JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote"

      When I tried to deploy again my application, after restarting JBoss with the previous options, I got the
      following error when JBoss tried deploying my application:


      11:59:54,239 ERROR [STDERR] java.lang.RuntimeException: Error creating MBeanProxy: DefaultDomain:service=timer
      11:59:54,241 ERROR [STDERR] at org.jboss.mx.util.MBeanProxyExt.init(MBeanProxyExt.java:415)
      11:59:54,242 ERROR [STDERR] at org.jboss.mx.util.MBeanProxyExt.(MBeanProxyExt.java:99)
      11:59:54,243 ERROR [STDERR] at org.jboss.mx.util.MBeanProxyExt.create(MBeanProxyExt.java:394)
      11:59:54,244 ERROR [STDERR] at org.jboss.mx.util.MBeanProxyExt.create(MBeanProxyExt.java:349)
      11:59:54,245 ERROR [STDERR] at org.jboss.injection.DependsFieldInjector.inject(DependsFieldInjector.java:65)
      11:59:54,246 ERROR [STDERR] at org.jboss.injection.DependsFieldInjector.inject(DependsFieldInjector.java:50)
      11:59:54,247 ERROR [STDERR] at org.jboss.ejb3.service.ServiceContainer.injectDependencies(ServiceContainer.java:337)
      11:59:54,249 ERROR [STDERR] at org.jboss.ejb3.service.ServiceContainer.start(ServiceContainer.java:145)
      11:59:54,256 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      11:59:54,258 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      11:59:54,365 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      11:59:54,365 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
      11:59:54,365 ERROR [STDERR] at org.jboss.ejb3.ServiceDelegateWrapper.startService(ServiceDelegateWrapper.java:102)
      11:59:54,365 ERROR [STDERR] at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
      11:59:54,366 ERROR [STDERR] at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
      11:59:54,366 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
      11:59:54,366 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      11:59:54,366 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
      11:59:54,366 ERROR [STDERR] at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
      11:59:54,366 ERROR [STDERR] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
      11:59:54,366 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
      11:59:54,366 ERROR [STDERR] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
      11:59:54,367 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
      11:59:54,367 ERROR [STDERR] at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
      11:59:54,367 ERROR [STDERR] at $Proxy0.start(Unknown Source)
      11:59:54,367 ERROR [STDERR] at org.jboss.system.ServiceController.start(ServiceController.java:417)
      11:59:54,367 ERROR [STDERR] at org.jboss.system.ServiceController.start(ServiceController.java:435)
      11:59:54,367 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
      11:59:54,367 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      11:59:54,367 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
      11:59:54,367 ERROR [STDERR] at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
      11:59:54,368 ERROR [STDERR] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
      11:59:54,368 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
      11:59:54,368 ERROR [STDERR] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
      11:59:54,368 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
      11:59:54,368 ERROR [STDERR] at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
      11:59:54,368 ERROR [STDERR] at $Proxy4.start(Unknown Source)
      11:59:54,368 ERROR [STDERR] at org.jboss.deployment.SARDeployer.start(SARDeployer.java:302)
      11:59:54,368 ERROR [STDERR] at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
      11:59:54,368 ERROR [STDERR] at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
      11:59:54,368 ERROR [STDERR] at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
      11:59:54,369 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor11.invoke(Unknown Source)
      11:59:54,369 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      11:59:54,369 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
      11:59:54,369 ERROR [STDERR] at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
      11:59:54,369 ERROR [STDERR] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
      11:59:54,369 ERROR [STDERR] at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
      11:59:54,370 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
      11:59:54,370 ERROR [STDERR] at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
      11:59:54,370 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
      11:59:54,370 ERROR [STDERR] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
      11:59:54,370 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
      11:59:54,370 ERROR [STDERR] at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
      11:59:54,370 ERROR [STDERR] at $Proxy6.deploy(Unknown Source)
      11:59:54,370 ERROR [STDERR] at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
      11:59:54,370 ERROR [STDERR] at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)
      11:59:54,371 ERROR [STDERR] at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
      11:59:54,371 ERROR [STDERR] at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274)
      11:59:54,371 ERROR [STDERR] at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225)
      11:59:54,372 ERROR [STDERR] Caused by: javax.management.InstanceNotFoundException: DefaultDomain:service=timer
      11:59:54,372 ERROR [STDERR] at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1010)
      11:59:54,372 ERROR [STDERR] at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBeanInfo(DefaultMBeanServerInterceptor.java:1303)
      11:59:54,372 ERROR [STDERR] at com.sun.jmx.mbeanserver.JmxMBeanServer.getMBeanInfo(JmxMBeanServer.java:903)
      11:59:54,372 ERROR [STDERR] at org.jboss.mx.util.MBeanProxyExt.init(MBeanProxyExt.java:407)
      11:59:54,372 ERROR [STDERR] ... 58 more
      12:04:53,153 INFO [Server] Runtime shutdown hook called, forceHalt: true

      Then I decided to check from jboss jmx-console if the Timer was there, and from the web page I can see it...(with the correct name: DefaultDomain:service=timer)

      I'm curious to understand the reason of the problem, if there is some expert that is willing to explain it ;-)

      Thanks in advance,
      Andrea