title: Unable to lookup TimerManager resources in Weblogic
body: <p>I am trying to lookup a TimerManager resource on a Weblogic Enterprise Application, but no matter what I try I always get a NameNotFoundException. I've been looking at a lot of different solutions online, but haven't found one that works yet:</p>
  
  <p>Here's my ejb-jar.xml:</p>
  
  <pre><code>&lt;ejb-jar&gt;
      &lt;enterprise-beans&gt;
          &lt;session&gt;
              &lt;ejb-name&gt;TimerBean&lt;/ejb-name&gt;
              &lt;remote&gt;ejb.generated.TimerBeanRemote&lt;/remote&gt;  
              &lt;local&gt;ejb.generated.TimerBeanLocal&lt;/local&gt;
              &lt;home&gt;ejb.generated.TimerBeanHomeRemote&lt;/home&gt;
              &lt;local-home&gt;ejb.generated.TimerBeanHomeLocal&lt;/local-home&gt;
              &lt;ejb-class&gt;ejb.TimerBean&lt;/ejb-class&gt;
              &lt;session-type&gt;Stateless&lt;/session-type&gt;
              &lt;transaction-type&gt;Container&lt;/transaction-type&gt;
  
              &lt;resource-ref&gt;
                  &lt;res-ref-name&gt;tm/TimerController&lt;/res-ref-name&gt;
                  &lt;res-type&gt;commonj.timers.TimerManager&lt;/res-type&gt;
                  &lt;res-auth&gt;Container&lt;/res-auth&gt;
                  &lt;res-sharing-scope&gt;Unshareable&lt;/res-sharing-scope&gt;
              &lt;/resource-ref&gt;
          &lt;/session&gt;
      &lt;/enterprise-beans&gt;
  &lt;/ejb-jar&gt;
  </code></pre>
  
  <p>My weblogic-ejb-jar.xml:</p>
  
  <pre><code>&lt;weblogic-ejb-jar&gt;
      &lt;weblogic-enterprise-bean&gt;
          &lt;ejb-name&gt;TimerBean&lt;/ejb-name&gt;
          &lt;local-jndi-name&gt;TimerBeanLocal&lt;/local-jndi-name&gt;
          &lt;jndi-name&gt;ejb/TimerBeanRemote&lt;/jndi-name&gt;
      &lt;dispatch-policy&gt;ejb-workmanagement&lt;/dispatch-policy&gt;
  
      &lt;reference-descriptor&gt;
          &lt;resource-description&gt;
              &lt;res-ref-name&gt;tm/TimerController&lt;/res-ref-name&gt;
              &lt;jndi-name&gt;TimerController&lt;/jndi-name&gt;
              &lt;res-type&gt;commonj.timers.TimerManager&lt;/res-type&gt;
              &lt;res-auth&gt;Container&lt;/res-auth&gt;
              &lt;res-sharing-scope&gt;Unshareable&lt;/res-sharing-scope&gt;
          &lt;/resource-description&gt;
      &lt;/reference-descriptor&gt;
  &lt;/weblogic-ejb-jar&gt;
  </code></pre>
  
  <p>And my Bean:</p>
  
  <pre><code>// xdocklet generated.
  public abstract class TimerBean implements SessionBean {
    public void ejbCreate() {
      Context context = new InitialContext();
      TimerManager mgr = (TimerManager) context.lookup("java:comp/env/tm/TimerController");
      // ...
    }
  }
  </code></pre>
  
  <p>I've tried looking up <code>"java:comp/env/tm/TimerController"</code>, <code>"java:/comp/env/tm/TimerController"</code>, <code>"tm/TimerController"</code>... Nothing seems to work, I always end up with a NameNotFoundException, always from the entire string, except the <code>java:</code> part, as the remaining name (i.e. it doesn't find anything at all).</p>
  
  <p><strong>edit</strong> it also seems that my TimerController resource is not present in Weblogic's jndi tree page.</p>
  
  <p><strong>edit2</strong> After listing the objects in the <code>java:comp/env</code> context using  <code>context.list("java:comp/env")</code> it seems that indeed it is ignoring the resource-ref. I'll investigate further.</p>
  
  <p>Here's the full stack trace:</p>
  
  <pre><code>javax.naming.NameNotFoundException: While trying to look up comp/env/tm/TimerController in /app/ejb/my-app-ejb-1.0.0-SNAPSHOT.jar#TimerBean.; remaining name 'comp/env/tm/TimerController'
  at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139)
  at weblogic.jndi.internal.ApplicationNamingNode.lookup(ApplicationNamingNode.java:144)
  at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:254)
  at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:380)
  at weblogic.jndi.factories.java.ReadOnlyContextWrapper.lookup(ReadOnlyContextWrapper.java:45)
  at weblogic.jndi.internal.AbstractURLContext.lookup(AbstractURLContext.java:130)
  at javax.naming.InitialContext.lookup(InitialContext.java:392)
  at ejb.TimerBean.ejbCreate(TimerBean.java:55)
  at ejb.TimerBean_sxsqua_Impl.ejbCreate(TimerBean_sxsqua_Impl.java:162)
  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:597)
  at weblogic.ejb.container.pool.StatelessSessionPool.createBean(StatelessSessionPool.java:205)
  at weblogic.ejb.container.pool.Pool.createInitialBeans(Pool.java:300)
  at weblogic.ejb.container.manager.StatelessManager.initializePool(StatelessManager.java:444)
  at weblogic.ejb.container.deployer.EJBDeployer.initializePools(EJBDeployer.java:1546)
  at weblogic.ejb.container.deployer.EJBDeployer.start(EJBDeployer.java:1377)
  at weblogic.ejb.container.deployer.EJBModule.start(EJBModule.java:589)
  at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:117)
  at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:204)
  at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
  at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)
  at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27)
  at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:635)
  at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
  at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:212)
  at weblogic.application.internal.EarDeployment.activate(EarDeployment.java:16)
  at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:162)
  at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)
  at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:569)
  at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:140)
  at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:106)
  at weblogic.deploy.internal.targetserver.operations.StartOperation.doCommit(StartOperation.java:143)
  at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:323)
  at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:820)
  at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1227)
  at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:436)
  at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:163)
  at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:181)
  at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:12)
  at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:67)
  at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:516)
  at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
  at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
  </code></pre>