title: javax.naming.NameNotFoundException: admin.sessionbeans.AdminSessionBeanRemote#admin.sessionbeans.AdminSessionBeanRemote not found
body: <p>I'm trying to create an enterprise application in the following environment (the one with Java EE, EJB and WAR modules). I'm following <a href="http://netbeans.org/kb/docs/javaee/entappclient.html" rel="nofollow">these</a> instructions (which are not about a web application though, I couldn't locate any article about a web application).</p>
  
  <ul>
  <li>NetBeans 7.2.1</li>
  <li>Glassfish Server 3.1.2 (containing the Servlet 3.0 API)</li>
  <li>EJB 3.1</li>
  <li>JPA 2.0</li>
  <li>JSF 2.1</li>
  <li>Oracle 10g</li>
  </ul>
  
  <p>I have created a Class Library (New Project -> Java -> Java Class Library) to place remote (<code>javax.ejb.Remote</code>) interface(s) which is to be implemented by a stateless session bean. The Class Library has been added on the class path of both of the modules (EJB and WAR). </p>
  
  <p>When an attempt is made to run this application, the following exception is caused.</p>
  
  <pre><code>com.sun.faces.mgbean.ManagedBeanCreationException: An error occurred performing resource injection on managed bean transporterBean
          at com.sun.faces.mgbean.BeanBuilder.injectResources(BeanBuilder.java:211)
          at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:103)
          at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:409)
          at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:269)
          at com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:244)
          at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:116)
          at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
          at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
          at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:103)
          at com.sun.el.parser.AstValue.getValue(AstValue.java:179)
          at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:224)
          at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
          at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
          at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
          at javax.faces.component.UIData.getValue(UIData.java:731)
          at javax.faces.component.UIData.getDataModel(UIData.java:1798)
          at javax.faces.component.UIData.setRowIndexWithoutRowStatePreserved(UIData.java:484)
          at javax.faces.component.UIData.setRowIndex(UIData.java:473)
          at com.sun.faces.renderkit.html_basic.TableRenderer.encodeBegin(TableRenderer.java:81)
          at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:820)
          at javax.faces.component.UIData.encodeBegin(UIData.java:1118)
          at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1755)
          at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
          at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
          at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402)
          at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
          at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
          at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
          at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
          at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
          at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
          at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
          at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
          at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
          at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
          at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
          at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
          at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
          at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
          at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
          at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
          at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
          at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
          at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
          at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
          at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
          at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
          at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
          at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
          at java.lang.Thread.run(Thread.java:722)
  Caused by: com.sun.faces.spi.InjectionProviderException: com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting to inject Remote ejb-ref name=managedbeans.TransporterBean/adminSessionBeanRemote,Remote 3.x interface =admin.sessionbeans.AdminSessionBeanRemote,ejb-link=null,lookup=,mappedName=,jndi-name=admin.sessionbeans.AdminSessionBeanRemote,refType=Session into class managedbeans.TransporterBean: Lookup failed for 'java:comp/env/managedbeans.TransporterBean/adminSessionBeanRemote' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}
          at org.glassfish.faces.integration.GlassFishInjectionProvider.inject(GlassFishInjectionProvider.java:194)
          at com.sun.faces.mgbean.BeanBuilder.injectResources(BeanBuilder.java:205)
          ... 53 more
  Caused by: com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting to inject Remote ejb-ref name=managedbeans.TransporterBean/adminSessionBeanRemote,Remote 3.x interface =admin.sessionbeans.AdminSessionBeanRemote,ejb-link=null,lookup=,mappedName=,jndi-name=admin.sessionbeans.AdminSessionBeanRemote,refType=Session into class managedbeans.TransporterBean: Lookup failed for 'java:comp/env/managedbeans.TransporterBean/adminSessionBeanRemote' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}
          at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:703)
          at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:470)
          at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.injectInstance(InjectionManagerImpl.java:171)
          at org.glassfish.faces.integration.GlassFishInjectionProvider.inject(GlassFishInjectionProvider.java:184)
          ... 54 more
  Caused by: javax.naming.NamingException: Lookup failed for 'java:comp/env/managedbeans.TransporterBean/adminSessionBeanRemote' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: Exception resolving Ejb for 'Remote ejb-ref name=managedbeans.TransporterBean/adminSessionBeanRemote,Remote 3.x interface =admin.sessionbeans.AdminSessionBeanRemote,ejb-link=null,lookup=,mappedName=,jndi-name=admin.sessionbeans.AdminSessionBeanRemote,refType=Session' .  Actual (possibly internal) Remote JNDI name used for lookup is 'admin.sessionbeans.AdminSessionBeanRemote#admin.sessionbeans.AdminSessionBeanRemote' [Root exception is javax.naming.NamingException: Lookup failed for 'admin.sessionbeans.AdminSessionBeanRemote#admin.sessionbeans.AdminSessionBeanRemote' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: admin.sessionbeans.AdminSessionBeanRemote#admin.sessionbeans.AdminSessionBeanRemote not found]]]
          at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518)
          at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
          at javax.naming.InitialContext.lookup(InitialContext.java:411)
          at javax.naming.InitialContext.lookup(InitialContext.java:411)
          at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:599)
          ... 57 more
  Caused by: javax.naming.NamingException: Exception resolving Ejb for 'Remote ejb-ref name=managedbeans.TransporterBean/adminSessionBeanRemote,Remote 3.x interface =admin.sessionbeans.AdminSessionBeanRemote,ejb-link=null,lookup=,mappedName=,jndi-name=admin.sessionbeans.AdminSessionBeanRemote,refType=Session' .  Actual (possibly internal) Remote JNDI name used for lookup is 'admin.sessionbeans.AdminSessionBeanRemote#admin.sessionbeans.AdminSessionBeanRemote' [Root exception is javax.naming.NamingException: Lookup failed for 'admin.sessionbeans.AdminSessionBeanRemote#admin.sessionbeans.AdminSessionBeanRemote' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: admin.sessionbeans.AdminSessionBeanRemote#admin.sessionbeans.AdminSessionBeanRemote not found]]
          at com.sun.ejb.EjbNamingReferenceManagerImpl.resolveEjbReference(EjbNamingReferenceManagerImpl.java:191)
          at com.sun.enterprise.container.common.impl.ComponentEnvManagerImpl$EjbReferenceProxy.create(ComponentEnvManagerImpl.java:1109)
          at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:776)
          at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:744)
          at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:169)
          at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:498)
          ... 61 more
  Caused by: javax.naming.NamingException: Lookup failed for 'admin.sessionbeans.AdminSessionBeanRemote#admin.sessionbeans.AdminSessionBeanRemote' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: admin.sessionbeans.AdminSessionBeanRemote#admin.sessionbeans.AdminSessionBeanRemote not found]
          at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518)
          at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
          at javax.naming.InitialContext.lookup(InitialContext.java:411)
          at javax.naming.InitialContext.lookup(InitialContext.java:411)
          at com.sun.ejb.EjbNamingReferenceManagerImpl.resolveEjbReference(EjbNamingReferenceManagerImpl.java:186)
          ... 66 more
  Caused by: javax.naming.NameNotFoundException: admin.sessionbeans.AdminSessionBeanRemote#admin.sessionbeans.AdminSessionBeanRemote not found
          at com.sun.enterprise.naming.impl.TransientContext.doLookup(TransientContext.java:248)
          at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:215)
          at com.sun.enterprise.naming.impl.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:77)
          at com.sun.enterprise.naming.impl.LocalSerialContextProviderImpl.lookup(LocalSerialContextProviderImpl.java:119)
          at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:505)
          ... 70 more
  </code></pre>
  
  <hr>
  
  <p>The remote interface is as follows.</p>
  
  <pre><code> package admin.sessionbeans;
  
  import entities.Transporter;
  import java.util.List;
  import javax.ejb.Remote;
  
  @Remote(AdminSessionBeanRemote.class)
  public interface AdminSessionBeanRemote 
  {
      public List&lt;Transporter&gt; getAllTransporters(); 
  }
  </code></pre>
  
  <p>The stateless session bean.</p>
  
  <pre><code>package admin.sessionbeans;
  
  import entities.Transporter;
  import java.util.List;
  import javax.ejb.Stateless;
  import javax.persistence.EntityManager;
  import javax.persistence.PersistenceContext;
  
  @Stateless//(mappedName="adminSessionBean")
  public class AdminSessionBean implements AdminSessionBeanRemote {
  
      @PersistenceContext(unitName="wagafashion-ejbPU")
      private EntityManager entityManager;
  
      @Override
      public List&lt;Transporter&gt; getAllTransporters() 
      {
          return entityManager.createNamedQuery("Transporter.findAll").getResultList();
      }
  }
  </code></pre>
  
  <p>The JSF managed bean.</p>
  
  <pre><code>package managedbeans;
  
  import admin.sessionbeans.AdminSessionBeanRemote;
  import entities.Transporter;
  import java.util.List;
  import javax.ejb.EJB;
  import javax.faces.bean.ManagedBean;
  import javax.faces.bean.RequestScoped;
  
  @ManagedBean
  @RequestScoped
  public final class TransporterBean 
  {
      @EJB
      private AdminSessionBeanRemote adminSessionBeanRemote;
      private List&lt;Transporter&gt;transporters;
  
      public TransporterBean() 
      {
  
      }
  
      public List&lt;Transporter&gt; getTransporters()
      {
          transporters=adminSessionBeanRemote.getAllTransporters();
          return transporters;
      }
  
      public void setTransporters(List&lt;Transporter&gt; transporters) 
      {
          this.transporters = transporters;
      }
  }
  </code></pre>
  
  <p>I have added all the <strong>entity classes</strong> to the Class Library according to <a href="http://netbeans.org/bugzilla/show_bug.cgi?id=192634#c4" rel="nofollow">this comment</a>.</p>
  
  <blockquote>
    <p>The client jar should contain the remote interfaces plus any classes
    these interfaces depend on</p>
  </blockquote>
  
  <hr>
  
  <p>A year or so ago, when I was working with NetBeans 6.9.1, I have developed some such applications. That version of IDE  doesn't mandate to place the remote interfaces in a separate Class Library. </p>
  
  <p>I have NetBeans IDE 6.9.1 still installed on my PC and I have tried to create the same application (without a separate Class Library, the remote interfaces are in the same EJB module) and it worked as intended.</p>
  
  <p>One last thing : when I remove this Class Library from both the modules (EJB and WAR) and deploy only the Java EE module (the one which is denoted by a triangle in NetBeans), it performs its intended function, retrieves data from the database and displays on the JSF page.</p>
  
  <p>So, I'm very much confused about the cause of this exception and cannot say for sure whether it is because of Class Library problem or other required configurations that I'm likely to be missing (though presumably, there might be some JNDI look up problems that I don't know).</p>
  
  <hr>
  
  <p>If someone had a link that says about how to create an enterprise web application in NetBeans 7.x, then it would be very helpful.</p>