8 Replies Latest reply on Aug 2, 2005 2:12 PM by Adam Warski

    Timer bean injection into service bean problem

    Adam Warski Master

      Hello,
      I've got a very weird problem, as my code runs on my computer, but doesn't work on others. So, I have a timer bean with a local interface:

      @Stateless
      @Local(MyTimerLocal.class)
      public class MyTimer implements MyTimerLocal {
      private @Resource SessionContext ctx;
      (...)
      @Timeout
      public void timeoutHandler(Timer timer) { } }

      I also have a service bean. I would like to inject the timer bean into my service bean, to be able to start the timer to do some cron-like action.
      So I've got:

      @Service
      @Local(MyServiceLocal.class)
      @Remote(MyServiceRemote.class)
      public class MyService implements MyServiceLocal, MyServiceManagement, MyServiceRemote {
      (...)
      @EJB
      private MyTimerLocal timer;
      (...) } }

      This works without any problems on my computer. On others however, during startup I get the exception:

      java.lang.RuntimeException: Unable to @Inject jndi dependency: timer into field private myservice.MyTimerLocal myservice.MyService.timer of class myservice.MyService
      at org.jboss.ejb3.injection.JndiFieldInjector.inject(JndiFieldInjector.java:50)
      (...)
      Caused by: javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: myservice.MyTimerLocal not bound]
      (...)

      Later, when I go check the jndi view on the jmx-console, I see that there is a myservice.MyTimerLocal binding. So my only guess is that somehow the timer bean on my computer gets deployed before the service bean, and on others the order is different. Can I explicitly specify the order in which beans get deployed? Maybe there's another explanation?

      --
      Adam

        • 1. Re: Timer bean injection into service bean problem
          Bill Burke Master

          Looks like a bug...I'll log on JIRA and see if I can fix it for the next release (tomorrow).

          • 2. Re: Timer bean injection into service bean problem
            Bill Burke Master

            Can you post the full stack trace? I need to know when/where JndiFieldInjector is being invoked. You say this happens at deployment?

            I can't see in code where this would be a problem...

            BIll

            • 3. Re: Timer bean injection into service bean problem
              Adam Warski Master

              Here it is:

              10:47:51,790 INFO [EARDeployer] Init J2EE application: file:/usr/local/forge/portal/jboss-4.0.3RC1/server/all/deploy/jboss-forge.ear/
              10:47:56,147 INFO [JaccHelper] Initialising JACC Context for deployment: forge-service.ejb3
              10:47:57,275 INFO [Ejb3Module] found EJB3 service bean: org.jboss.forge.service.ForgeService
              10:47:58,264 INFO [JaccHelper] org.jboss.forge.service.ForgeService has no @SecurityDomain - skipping JACC configuration
              10:47:58,296 INFO [Ejb3AnnotationHandler] found EJB3: ejbName=org.jboss.forge.service.ForgeTimer, class=org.jboss.forge.service.ForgeTimer, type=STATELESS
              10:47:58,398 INFO [JaccHelper] org.jboss.forge.service.ForgeTimer has no @SecurityDomain - skipping JACC configuration
              10:47:58,403 INFO [JaccHelper] JACC Policy Configuration for deployment has been put in service
              10:47:58,413 INFO [Ejb3Module] EJB3 deployment time took: 2273
              10:47:58,719 INFO [ProxyDeployer] no declared remote bindings
              10:47:58,724 INFO [ProxyDeployer] there is remote interfaces
              10:47:58,725 INFO [ProxyDeployer] default remote binding has jndiName of org.jboss.forge.service.ForgeServiceRemote
              10:47:59,550 WARN [ServiceController] Problem creating service forge:service=cacheAndUpdate
              java.lang.RuntimeException: Unable to @Inject jndi dependency: timer into field private org.jboss.forge.service.ForgeTimerLocal org.jboss.forge.service.ForgeService.timer of class org.jboss.forge.service.ForgeService
              at org.jboss.ejb3.injection.JndiFieldInjector.inject(JndiFieldInjector.java:50)
              at org.jboss.ejb3.service.ServiceContainer.injectDependencies(ServiceContainer.java:229)
              at org.jboss.ejb3.service.ServiceContainer.populateInvocation(ServiceContainer.java:204)
              at org.jboss.ejb3.service.ServiceContainer.localInvoke(ServiceContainer.java:144)
              at org.jboss.ejb3.service.ServiceContainer.localInvoke(ServiceContainer.java:121)
              at org.jboss.ejb3.service.ServiceMBeanDelegate.invoke(ServiceMBeanDelegate.java:155)
              at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:150)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
              at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:967)
              at $Proxy0.create(Unknown Source)
              at org.jboss.system.ServiceController.create(ServiceController.java:342)
              at org.jboss.system.ServiceController.create(ServiceController.java:281)
              at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
              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:141)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
              at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
              at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
              at $Proxy85.create(Unknown Source)
              at org.jboss.ejb3.service.ServiceMBeanDelegate.register(ServiceMBeanDelegate.java:72)
              at org.jboss.ejb3.service.ServiceContainer.registerManagementInterface(ServiceContainer.java:300)
              at org.jboss.ejb3.service.ServiceContainer.start(ServiceContainer.java:74)
              at org.jboss.ejb3.service.ServiceManager.startService(ServiceManager.java:67)
              at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:267)
              at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:217)
              at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
              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:141)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
              at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
              at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:950)
              at $Proxy0.start(Unknown Source)
              at org.jboss.system.ServiceController.start(ServiceController.java:436)
              at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
              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:141)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
              at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
              at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
              at $Proxy72.start(Unknown Source)
              at org.jboss.ejb3.Ejb3Module.startService(Ejb3Module.java:313)
              at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:267)
              at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:217)
              at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
              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:141)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
              at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
              at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:950)
              at $Proxy0.start(Unknown Source)
              at org.jboss.system.ServiceController.start(ServiceController.java:436)
              at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
              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:141)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
              at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
              at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
              at $Proxy17.start(Unknown Source)
              at org.jboss.ejb3.EJB3Deployer.start(EJB3Deployer.java:177)
              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:141)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
              at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:118)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
              at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
              at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
              at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
              at $Proxy18.start(Unknown Source)
              at org.jboss.deployment.MainDeployer.start(MainDeployer.java:973)
              at org.jboss.deployment.MainDeployer.start(MainDeployer.java:963)
              at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:774)
              at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:737)
              at sun.reflect.GeneratedMethodAccessor19.invoke(Unknown Source)
              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:141)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
              at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:118)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
              at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
              at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
              at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
              at $Proxy9.deploy(Unknown Source)
              at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:325)
              at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:501)
              at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:204)
              at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:277)
              at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:267)
              at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:217)
              at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
              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:141)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
              at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
              at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:950)
              at $Proxy0.start(Unknown Source)
              at org.jboss.system.ServiceController.start(ServiceController.java:436)
              at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
              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:141)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
              at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
              at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
              at $Proxy4.start(Unknown Source)
              at org.jboss.deployment.SARDeployer.start(SARDeployer.java:273)
              at org.jboss.deployment.MainDeployer.start(MainDeployer.java:973)
              at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:774)
              at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:737)
              at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:721)
              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:141)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
              at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:118)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
              at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
              at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
              at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
              at $Proxy5.deploy(Unknown Source)
              at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:434)
              at org.jboss.system.server.ServerImpl.start(ServerImpl.java:315)
              at org.jboss.Main.boot(Main.java:195)
              at org.jboss.Main$1.run(Main.java:463)
              at java.lang.Thread.run(Thread.java:595)
              Caused by: javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: org.jboss.forge.service.ForgeTimerLocal not bound]
              at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1052)
              at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:685)
              at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
              at org.jboss.ejb3.injection.JndiFieldInjector.inject(JndiFieldInjector.java:46)
              ... 155 more
              Caused by: javax.naming.NameNotFoundException: org.jboss.forge.service.ForgeTimerLocal not bound
              at org.jnp.server.NamingServer.getBinding(NamingServer.java:491)
              at org.jnp.server.NamingServer.getBinding(NamingServer.java:499)
              at org.jnp.server.NamingServer.getObject(NamingServer.java:505)
              at org.jnp.server.NamingServer.lookup(NamingServer.java:278)
              at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:610)
              at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
              at javax.naming.InitialContext.lookup(InitialContext.java:351)
              at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1046)
              ... 158 more
              10:47:59,632 INFO [ProxyDeployer] no declared remote bindings
              10:47:59,682 INFO [EJB3Deployer] Deployed: file:/usr/local/forge/portal/jboss-4.0.3RC1/server/all/deploy/jboss-forge.ear/forge-service.ejb3

              • 4. Re: Timer bean injection into service bean problem
                Bill Burke Master

                At first try, I cannot reproduce this...Can you post your management interface? Are you using the ServiceMBean interface?

                Thanks

                • 5. Re: Timer bean injection into service bean problem
                  Bill Burke Master

                  Do you have a create() and/or start() method?

                  Thanks

                  • 6. Re: Timer bean injection into service bean problem
                    Bill Burke Master

                    nevermind, I've reproduced the problem...

                    • 7. Re: Timer bean injection into service bean problem
                      Bill Burke Master

                      ok, fixed in CVS...Will be in later release.