0 Replies Latest reply on Jul 8, 2011 6:01 PM by iapazmino

    InitialContext doesn't use environment settings




      I'm trying to lookup a component deployed into a jboss as4.2.3. In order to do so I construct the context passing into the environment settings the provider's url. Since this server is running in my desktop at first I tough I was getting hold of the server but when printin the available bindings I saw only the local ones. Local y refer to the jboss as7 from where I want to get the ejb reference. So, I shut-down the as4.2 and nothing happened.


      Following my configuration





      getting the context

      private Context getContext(Hashtable<?, ?> environment) {
          try {
              return new InitialContext(environment);
          } catch (NamingException e) {
              final String host = (String) environment.get(Context.PROVIDER_URL);
              throw new RuntimeException("Server not found " + host, e);


      getting the ejb2 reference

      private Ejb2Interface getEjb2Interface() {
          final String jndi = Ejb2HomeInterface.JNDI_NAME;// jndi = ejb/module/EJB2Class
          try {
              Context context = getContext(ejb2AppProperties);
              ejb2Home = (Ejb2HomeInterface) context.lookup(jndi);
              return ejb2Home.create();
          } catch (NamingException e) {
              throw new RuntimeException("EJB2 not found " + jndi, e);
          } catch (RemoteException e) {
              throw new RuntimeException(e);
          } catch (CreateException e) {
              throw new RuntimeException(e);


      and the exception trace is

      Caused by: javax.naming.NameNotFoundException: Name 'ejb' not found in context ''
          at org.jboss.as.naming.util.NamingUtils.nameNotFoundException(NamingUtils.java:109)
          at org.jboss.as.naming.InMemoryNamingStore$NodeTraversingVisitor.visit(InMemoryNamingStore.java:365)
          at org.jboss.as.naming.InMemoryNamingStore$ContextNode.accept(InMemoryNamingStore.java:307)
          at org.jboss.as.naming.InMemoryNamingStore.lookup(InMemoryNamingStore.java:162)
          at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:173)
          at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:207)
          at javax.naming.InitialContext.lookup(InitialContext.java:392) [:1.6.0_24]


      What's the settings I'm missplacing/missing?