4 Replies Latest reply on May 6, 2011 4:48 PM by Tim Haley

    Singleton starting before dependency names bound

    klkoster Newbie

      I have converted my service beans to stateless singletons on AS 6.FINAL and those that have @EJB annotations (no transitive dependencies) are failing because of missing name bindings. The singletons are packaged in separate modules since they are orthogonal to the core EJB's of the application and represent long running background services that may or may not be deployed with the application (depending on the client's wishes). They are, however, bundled in the same EAR. The following stack trace is produced on deployment.

       

      09:27:33,984 INFO  [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:          kdr/remote/EnvrionmentObjectLoaderService - EJB3.x Default Remote Business Interface         risk-server/EnvironmentObjectLoaderServiceBean/remote-org.kdr.env.loader.EnvironmentObjectLo aderServiceRemote - EJB3.x Remote Business Interface         kdr/local/EnvrionmentObjectLoaderService - EJB3.x Default Local Business Interface         risk-server/EnvironmentObjectLoaderServiceBean/local-org.kdr.env.loader.EnvironmentObjectLoa derServiceLocal - EJB3.x Local Business Interface  09:27:34,035 ERROR [ServiceContainer] Encountered an error in start of EnvironmentObjectLoaderServic eBean: org.jboss.injection.manager.spi.InjectionException: javax.naming.NamingException: Could not d ereference object [Root exception is javax.naming.NameNotFoundException: EnvironmentObjectLoaderServ iceConfigurationManagement not bound]         at org.jboss.injection.injector.EEInjector.inject(EEInjector.java:87) [:1.0.0-alpha-6]         at org.jboss.injection.manager.core.DefaultInjectionContext.proceed(DefaultInjectionContext. java:58) [:1.0.0-alpha-6]         at org.jboss.injection.manager.core.DefaultInjectionManager.inject(DefaultInjectionManager.j ava:58) [:1.0.0-alpha-6]         at org.jboss.injection.manager.core.DefaultInjectionManager.inject(DefaultInjectionManager.j ava:64) [:1.0.0-alpha-6]         at org.jboss.ejb3.injection.InjectionInvocation.invokeTarget(InjectionInvocation.java:140) [ :1.7.17]         at org.jboss.ejb3.injection.InjectionInvocation.invokeNext(InjectionInvocation.java:125) [:1 .7.17]         at org.jboss.ejb3.core.context.CurrentInvocationContextInterceptor.invoke(CurrentInvocationC ontextInterceptor.java:47) [:1.7.17]         at org.jboss.ejb3.injection.InjectionInvocation.invokeNext(InjectionInvocation.java:116) [:1 .7.17]         at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocation Interceptor.java:67) [:1.0.1]         at org.jboss.ejb3.injection.InjectionInvocation.invokeNext(InjectionInvocation.java:116) [:1 .7.17]         at org.jboss.ejb3.EJBContainer.injectBeanContext(EJBContainer.java:1363) [:1.7.17]         at org.jboss.ejb3.service.ServiceContainer.injectDependencies(ServiceContainer.java:555) [:1 .7.17]         at org.jboss.ejb3.service.ServiceContainer.createBeanContext(ServiceContainer.java:151) [:1. 7.17]         at org.jboss.ejb3.service.ServiceContainer.initBeanContext(ServiceContainer.java:530) [:1.7. 17]         at org.jboss.ejb3.service.ServiceContainer.lockedStart(ServiceContainer.java:261) [:1.7.17]         at org.jboss.ejb3.EJBContainer.start(EJBContainer.java:1105) [:1.7.17]         at org.jboss.ejb3.service.ServiceContainer.start(ServiceContainer.java:796) [:1.7.17]         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_23]         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_23]          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1 .6.0_23]         at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_23]         at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:60) [ jboss-reflect.jar:2.2.0.GA]         at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImp l.java:168) [jboss-reflect.jar:2.2.0.GA]         at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66) [ jboss-reflect.jar:2.2.0.GA]         at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrappe r.execute(KernelControllerContextAction.java:257) [jboss-kernel.jar:2.2.0.GA]         at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47) [j boss-kernel.jar:2.2.0.GA]         at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrappe r(KernelControllerContextAction.java:125) [jboss-kernel.jar:2.2.0.GA]         at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(Kerne lControllerContextAction.java:72) [jboss-kernel.jar:2.2.0.GA]         at org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInternal(LifecycleAction .java:202) [jboss-kernel.jar:2.2.0.GA]         at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction .java:54) [jboss-kernel.jar:2.2.0.GA]         at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction .java:42) [jboss-kernel.jar:2.2.0.GA]         at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(Sim pleControllerContextAction.java:62) [jboss-dependency.jar:2.2.0.GA]         at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControlle rContextAction.java:71) [jboss-dependency.jar:2.2.0.GA]         at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerC ontextActions.java:51) [jboss-dependency.jar:2.2.0.GA]         at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext. java:379) [jboss-dependency.jar:2.2.0.GA]         at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jb oss-dependency.jar:2.2.0.GA]         at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:10 83) [jboss-dependency.jar:2.2.0.GA]         at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractC ontroller.java:1322) [jboss-dependency.jar:2.2.0.GA]         at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1 246) [jboss-dependency.jar:2.2.0.GA]         at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1 139) [jboss-dependency.jar:2.2.0.GA]         at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:894) [jbo ss-dependency.jar:2.2.0.GA]         at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:641) [jbo ss-dependency.jar:2.2.0.GA]         at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer. java:182) [:2.2.0.GA]         at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer. java:58) [:2.2.0.GA]         at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(Abstra ctSimpleRealDeployer.java:62) [:2.2.0.GA]         at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer .java:55) [:2.2.0.GA]         at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:179) [: 2.2.0.GA]         at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1832) [:2 .2.0.GA]         at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.ja va:1550) [:2.2.0.GA]         at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.ja va:1571) [:2.2.0.GA]         at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.ja va:1603) [:2.2.0.GA]         at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1491) [:2. 2.0.GA]         at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext. java:379) [jboss-dependency.jar:2.2.0.GA]         at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jb oss-dependency.jar:2.2.0.GA]         at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:10 83) [jboss-dependency.jar:2.2.0.GA]         at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractC ontroller.java:1322) [jboss-dependency.jar:2.2.0.GA]         at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1 246) [jboss-dependency.jar:2.2.0.GA]         at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1 139) [jboss-dependency.jar:2.2.0.GA]         at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939) [jbos s-dependency.jar:2.2.0.GA]         at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654) [jbos s-dependency.jar:2.2.0.GA]         at org.jboss.deployers.plugins.deployers.DeployersImpl.change(DeployersImpl.java:1983) [:2.2 .0.GA]         at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:1076) [:2. 2.0.GA]         at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:679) [:2. 2.0.GA]         at org.jboss.system.server.profileservice.deployers.MainDeployerPlugin.process(MainDeployerP lugin.java:106) [:6.0.0.Final]         at org.jboss.profileservice.dependency.ProfileControllerContext$DelegateDeployer.process(Pro fileControllerContext.java:143) [:0.2.2]         at org.jboss.profileservice.dependency.ProfileDeployAction.deploy(ProfileDeployAction.java:1 51) [:0.2.2]         at org.jboss.profileservice.dependency.ProfileDeployAction.installActionInternal(ProfileDepl oyAction.java:94) [:0.2.2]         at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction .java:54) [jboss-kernel.jar:2.2.0.GA]         at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction .java:42) [jboss-kernel.jar:2.2.0.GA]         at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(Sim pleControllerContextAction.java:62) [jboss-dependency.jar:2.2.0.GA]         at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControlle rContextAction.java:71) [jboss-dependency.jar:2.2.0.GA]         at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerC ontextActions.java:51) [jboss-dependency.jar:2.2.0.GA]         at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext. java:379) [jboss-dependency.jar:2.2.0.GA]         at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jb oss-dependency.jar:2.2.0.GA]         at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:10 83) [jboss-dependency.jar:2.2.0.GA]         at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractC ontroller.java:1322) [jboss-dependency.jar:2.2.0.GA]         at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1 246) [jboss-dependency.jar:2.2.0.GA]         at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1 139) [jboss-dependency.jar:2.2.0.GA]         at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939) [jbos s-dependency.jar:2.2.0.GA]         at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654) [jbos s-dependency.jar:2.2.0.GA]         at org.jboss.profileservice.dependency.ProfileActivationWrapper$BasicProfileActivation.start (ProfileActivationWrapper.java:190) [:0.2.2]         at org.jboss.profileservice.dependency.ProfileActivationWrapper.start(ProfileActivationWrapp er.java:87) [:0.2.2]         at org.jboss.profileservice.dependency.ProfileActivationService.activateProfile(ProfileActiv ationService.java:215) [:0.2.2]         at org.jboss.profileservice.dependency.ProfileActivationService.activate(ProfileActivationSe rvice.java:159) [:0.2.2]         at org.jboss.profileservice.bootstrap.AbstractProfileServiceBootstrap.activate(AbstractProfi leServiceBootstrap.java:112) [:0.2.2]         at org.jboss.profileservice.resolver.BasicResolverFactory$ProfileResolverFacade.deploy(Basic ResolverFactory.java:87) [:0.2.2]         at org.jboss.profileservice.bootstrap.AbstractProfileServiceBootstrap.start(AbstractProfileS erviceBootstrap.java:91) [:0.2.2]         at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(Basic ProfileServiceBootstrap.java:132) [:6.0.0.Final]         at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(Basic ProfileServiceBootstrap.java:56) [:6.0.0.Final]         at org.jboss.bootstrap.impl.base.server.AbstractServer.startBootstraps(AbstractServer.java:8 27) [jboss-bootstrap-impl-base.jar:2.1.0-alpha-5]         at org.jboss.bootstrap.impl.base.server.AbstractServer$StartServerTask.run(AbstractServer.ja va:417) [jboss-bootstrap-impl-base.jar:2.1.0-alpha-5]         at java.lang.Thread.run(Thread.java:662) [:1.6.0_23] Caused by: javax.naming.NamingException: Could not dereference object [Root exception is javax.namin g.NameNotFoundException: EnvironmentObjectLoaderServiceConfigurationManagement not bound]         at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1356) [:5.0.5.Final]         at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:819) [:5.0.5.Final]         at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:835) [:5.0.5.Final]         at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:688) [:5.0.5.Final]         at javax.naming.InitialContext.lookup(InitialContext.java:392) [:1.6.0_23]         at org.jboss.injection.injector.EEInjector.lookup(EEInjector.java:153) [:1.0.0-alpha-6]         at org.jboss.injection.injector.EEInjector.inject(EEInjector.java:133) [:1.0.0-alpha-6]         at org.jboss.injection.injector.EEInjector.inject(EEInjector.java:82) [:1.0.0-alpha-6]         ... 91 more Caused by: javax.naming.NameNotFoundException: EnvironmentObjectLoaderServiceConfigurationManagement  not bound         at org.jnp.server.NamingServer.getBinding(NamingServer.java:771) [:5.0.5.Final]         at org.jnp.server.NamingServer.getBinding(NamingServer.java:779) [:5.0.5.Final]         at org.jnp.server.NamingServer.getObject(NamingServer.java:785) [:5.0.5.Final]         at org.jnp.server.NamingServer.lookup(NamingServer.java:443) [:5.0.5.Final]         at org.jnp.server.NamingServer.lookup(NamingServer.java:399) [:5.0.5.Final]         at org.jnp.server.NamingServer.lookup(NamingServer.java:399) [:5.0.5.Final]         at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:728) [:5.0.5.Final]         at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:688) [:5.0.5.Final]         at javax.naming.InitialContext.lookup(InitialContext.java:392) [:1.6.0_23]         at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1350) [:5.0.5.Final]

       

      The singleton EJB is coded as follows:

       

      @Stateless

      @Singleton
      @Startup
      @Local(EnvironmentObjectLoaderServiceLocal.class)
      @Remote(EnvironmentObjectLoaderServiceRemote.class)
      @Management(IEnvironmentObjectLoaderServiceManagement.class)
      @LocalBinding(jndiBinding = "kdr/local/EnvrionmentObjectLoaderService")
      @RemoteBinding(jndiBinding = "kdr/remote/EnvrionmentObjectLoaderService")
      public class EnvironmentObjectLoaderServiceBean implements
              IEnvironmentObjectLoaderServiceManagement,
              EnvironmentObjectLoaderServiceLocal,
              EnvironmentObjectLoaderServiceRemote,
              IEnvironmentObjectLoaderEventListener {


          @EJB(mappedName = "kdr/local/EnvironmentObjectLoaderServiceConfigurationManagement")
          IEnvironmentObjectLoaderServiceConfigurationManagementLocal serviceConfigurationManagement;

       

          @EJB(mappedName = "kdr/local/EnvironmentObjectLoaderConfigurationManagement")
          IEnvironmentObjectLoaderConfigurationManagementLocal loaderConfigurationManagement;

       

          @EJB(mappedName = "kdr/local/EnvironmentObjectLoaderManagement")
          IEnvironmentObjectLoaderManagementLocal loaderManagement;

       

          @EJB(mappedName = "kdr/local/EnvironmentObjectManagement")
          EnvironmentObjectManagementLocal environmentObjectManagement;

       

          ... application specific code ...

       

      }

       

      In a separate EJB jar that is packaged in the same EAR, the service configuration bean is coded as follows:

       

      @Stateless
      @Clustered(loadBalancePolicy = "org.jboss.ha.client.loadbalance.RandomRobin", partition = "KDR")
      @Local({ IEnvironmentObjectLoaderServiceConfigurationManagementLocal.class })
      @LocalBinding(jndiBinding = "kdr/local/EnvironmentObjectLoaderServiceConfigurationManagement")
      @Remote({ IEnvironmentObjectLoaderServiceConfigurationManagementRemote.class })
      @RemoteBinding(jndiBinding = "kdr/remote/EnvironmentObjectLoaderServiceConfigurationManagement")
      @AspectDomain("KDR Stateless Bean")
      public class EnvironmentObjectLoaderServiceConfigurationManagementBean
              implements IEnvironmentObjectLoaderServiceConfigurationManagementLocal,
              IEnvironmentObjectLoaderServiceConfigurationManagementRemote,
              Serializable {

       

      .. application specific code ..

       

      }

       

      The application.xml is as follows where the core EJB's are packaged in kdr-common-ejb.jar and risk-ejb.jar (includes EnvironmentObjectLoaderServiceConfigurationManagementBean) ; and the EnvironmentObjectLoaderServiceBean is packaged in risk-ejb-env-loader.jar:

       

      <?xml version="1.0" encoding="UTF-8"?>
      <application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:application="http://java.sun.com/xml/ns/javaee/application_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd" id="Application_ID" version="5">
        <description>KDR Workbench</description>
        <display-name>KDR Workbench</display-name>
        <module>
          <ejb>kdr-common-ejb.jar</ejb>
        </module>
        <module>
          <ejb>risk-ejb.jar</ejb>
        </module>
        <module>
          <ejb>risk-ejb-fix.jar</ejb>
        </module>
        <module>
          <ejb>risk-ejb-cme.jar</ejb>
        </module>
        <module>
          <ejb>risk-ejb-ice.jar</ejb>
        </module>
        <module>
          <ejb>risk-ejb-trade-loader.jar</ejb>
        </module>
        <module>
          <ejb>risk-ejb-env-loader.jar</ejb>
        </module>
        <library-directory>lib</library-directory>
      </application>