3 Replies Latest reply on Mar 20, 2006 1:51 PM by Scott Tamosunas

    InitialContext.lookup throwing NameNotFoundException with jb

    Scott Tamosunas Newbie

      My call to ctx.lookup() is failing with a NameNotFoundException -not bound when trying to retrieve the remote interface to my stateless session bean. This seemed to be working with jboss-4.0.3SP1. Anyone have any idea on what I might be missing?

      I have the following code:

      
       public static AppManager getManager() {
       try {
       InitialContext ctx = new InitialContext();
       return (AppManager)ctx.lookup(AppManager.class.getName());
       } catch (Exception e) {
       e.printStackTrace();
       return null;
       }
       }
      


      This is trying to get back a session bean with a remote interface:

      @Remote
      public interface AppManager {
      
       public List getCampaigns();
       public void createCampaign(Campaign c);
      }
      
      




      @Stateless
      public class AppManagerBean implements AppManager {
      
       @PersistenceContext(unitName="admanagement")
       protected EntityManager em;
      
      
       public List getCampaigns() {
       return em.createQuery("from Campaign c").getResultList();
       }
      
      
       public void createCampaign(Campaign c) {
       em.persist(c);
       }
      
       public Campaign updateCampaign(Campaign c) {
       return em.merge(c);
       }
      
      


      When the call to ctx.lookup() is made, I get a NameNotFoundException - not bound:

      10:03:52,654 ERROR [STDERR] javax.naming.NameNotFoundException: com.mycompany.ejb.AppManager not bound
      10:03:52,654 ERROR [STDERR] at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
      10:03:52,654 ERROR [STDERR] at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
      10:03:52,654 ERROR [STDERR] at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
      10:03:52,654 ERROR [STDERR] at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
      10:03:52,654 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
      10:03:52,654 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
      10:03:52,654 ERROR [STDERR] at javax.naming.InitialContext.lookup(Unknown Source)
      10:03:52,654 ERROR [STDERR] at com.mycompany.web.Utils.getManager(Utils.java:18)
      10:03:52,654 ERROR [STDERR] at com.mycompany.web.CampaignBean.getCampaigns(CampaignBean.java:20)
      10:03:52,654 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      10:03:52,654 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      10:03:52,654 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      10:03:52,654 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source)
      10:03:52,654 ERROR [STDERR] at org.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.java:400)
      10:03:52,654 ERROR [STDERR] at org.apache.myfaces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:71)
      10:03:52,654 ERROR [STDERR] at org.apache.myfaces.el.ELParserHelper$MyPropertySuffix.evaluate(ELParserHelper.java:532)
      10:03:52,654 ERROR [STDERR] at org.apache.commons.el.ComplexValue.evaluate(ComplexValue.java:145)
      10:03:52,654 ERROR [STDERR] at org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:378)
      10:03:52,654 ERROR [STDERR] at javax.faces.component.UIData.getValue(UIData.java:779)
      10:03:52,654 ERROR [STDERR] at javax.faces.component.UIData.createDataModel(UIData.java:545)
      10:03:52,654 ERROR [STDERR] at javax.faces.component.UIData.getDataModel(UIData.java:534)
      10:03:52,654 ERROR [STDERR] at javax.faces.component.UIData.getRowCount(UIData.java:103)
      10:03:52,654 ERROR [STDERR] at org.apache.myfaces.renderkit.html.HtmlTableRendererBase.encodeInnerHtml(HtmlTableRendererBase.java:124)
      10:03:52,654 ERROR [STDERR] at org.apache.myfaces.renderkit.html.HtmlTableRendererBase.encodeChildren(HtmlTableRendererBase.java:94)
      10:03:52,654 ERROR [STDERR] at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:319)
      10:03:52,654 ERROR [STDERR] at javax.faces.webapp.UIComponentTag.encodeChildren(UIComponentTag.java:343)
      10:03:52,654 ERROR [STDERR] at javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:251)
      10:03:52,654 ERROR [STDERR] at org.apache.myfaces.taglib.UIComponentBodyTagBase.doEndTag(UIComponentBodyTagBase.java:55)
      10:03:52,654 ERROR [STDERR] at org.apache.jsp.testme_jsp._jspx_meth_h_dataTable_0(org.apache.jsp.testme_jsp:261)
      10:03:52,654 ERROR [STDERR] at org.apache.jsp.testme_jsp._jspx_meth_f_view_0(org.apache.jsp.testme_jsp:134)
      10:03:52,654 ERROR [STDERR] at org.apache.jsp.testme_jsp._jspService(org.apache.jsp.testme_jsp:78)
      10:03:52,654 ERROR [STDERR] at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
      10:03:52,654 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      10:03:52,654 ERROR [STDERR] at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
      10:03:52,654 ERROR [STDERR] at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
      10:03:52,654 ERROR [STDERR] at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
      10:03:52,654 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      10:03:52,654 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      10:03:52,654 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      10:03:52,654 ERROR [STDERR] at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
      10:03:52,654 ERROR [STDERR] at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
      10:03:52,654 ERROR [STDERR] at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
      10:03:52,654 ERROR [STDERR] at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
      10:03:52,654 ERROR [STDERR] at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:415)
      10:03:52,654 ERROR [STDERR] at org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:234)
      10:03:52,654 ERROR [STDERR] at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:352)
      10:03:52,654 ERROR [STDERR] at javax.faces.webapp.FacesServlet.service(FacesServlet.java:107)
      10:03:52,654 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      10:03:52,654 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      10:03:52,654 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      10:03:52,654 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      10:03:52,654 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      10:03:52,654 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      10:03:52,654 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      10:03:52,654 ERROR [STDERR] at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:54)
      10:03:52,654 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:174)
      10:03:52,654 ERROR [STDERR] at org.jboss.web.tomcat.tc5.session.ClusteredSessionValve.invoke(ClusteredSessionValve.java:95)
      10:03:52,654 ERROR [STDERR] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
      10:03:52,654 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
      10:03:52,654 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      10:03:52,654 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      10:03:52,654 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      10:03:52,654 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      10:03:52,654 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
      10:03:52,654 ERROR [STDERR] at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
      10:03:52,654 ERROR [STDERR] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      10:03:52,654 ERROR [STDERR] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      10:03:52,654 ERROR [STDERR] at java.lang.Thread.run(Unknown Source)