title: Java JNDI lookup failing on JBoss AS 6 from external Java program
body: <p>I am upgrading from JBoss AS 4.0.4.GA to JBoss 6.0.0.Final.
  I have been unable to lookup a HornetQ Topic from an external Java client, so I decided to write a little test Java program that did a simple lookup of a DataSource. That lookup is failing. I can see the DataSource in the web console and it has:</p>
  
  <pre><code>Pool JNDI Name = MyDS
  </code></pre>
  
  <p>I used to (with JBoss 4.0.4.GA) lookup the DataSource using "java:/MyDS", but that is not working. I have seen some talk about not being able to lookup objects (Queues,Topics,DataSources,EJBs,etc) from outside the AS. I'd be surprised if that is the case, but if it is, then how do I disable that "feature"?</p>
  
  <p>The DS is in server/myconf/deploy/mysql-ds.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;datasources&gt;
      &lt;local-tx-datasource&gt;
          &lt;jndi-name&gt;MyDS&lt;/jndi-name&gt;
          &lt;connection-url&gt;jdbc:mysql://localhost:3306/mydb&lt;/connection-url&gt;
          &lt;driver-class&gt;com.mysql.jdbc.Driver&lt;/driver-class&gt;
          &lt;user-name&gt;xxxxxxxx&lt;/user-name&gt;
          &lt;password&gt;xxxxxxxx&lt;/password&gt;
          &lt;prepared-statement-cache-size&gt;50&lt;/prepared-statement-cache-size&gt;
          &lt;min-pool-size&gt;20&lt;/min-pool-size&gt;
          &lt;max-pool-size&gt;40&lt;/max-pool-size&gt;
          &lt;metadata&gt;
              &lt;type-mapping&gt;mySQL&lt;/type-mapping&gt;
          &lt;/metadata&gt;
      &lt;/local-tx-datasource&gt;
  &lt;/datasources&gt;
  </code></pre>
  
  <p>The Java program that looks up the DS is:</p>
  
  <pre><code>env.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
  env.put(javax.naming.Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
  env.put(javax.naming.Context.PROVIDER_URL, "jnp://localhost:1099");
  
  InitialContext ctx = new InitialContext(env);
  Object o = ctx.lookup("java:/MyDS");
  </code></pre>
  
  <p>The lookup line throws a NameNotFoundException:</p>
  
  <pre><code>javax.naming.NameNotFoundException: MyDS not bound
  </code></pre>
  
  <p>I've tried the lookup with just "MyDS" rather than "java:/MyDS", but it still fails. I don't think the problem is the name I'm using to lookup, rather something preventing me doing any lookup from an external application - and if that is the case, I need to enable such lookups.</p>