3 Replies Latest reply on Jan 5, 2005 5:07 PM by jgra

    JNDI and DataSources

    ajaykrishnan

      I have successfully bound a DataSource to the naming service:

      [WrapperDataSourceService] Bound connection factory for resource adapter for ConnectionManager 'jboss.jca:name=MySqlDS,service=DataSourceBinding to JNDI name 'java:MySqlDS'


      Objects deployed in the Application Server are able to look this up using:
       private String initialContextFactory = "org.jnp.interfaces.NamingContextFactory";
       private String url = "localhost:1099";
       private String namingFactoryURLPackages = "org.jboss.naming:org.jnp.interfaces";
      
       env = new Properties();
       env.setProperty(Context.INITIAL_CONTEXT_FACTORY, initialContextFactory);
       env.setProperty(Context.PROVIDER_URL, url);
       env.setProperty(Context.URL_PKG_PREFIXES, namingFactoryURLPackages);
       try {
       ctx = new InitialContext(env);
       Object o = ctx.lookup("java:MySqlDS");
       } catch (NamingException e) {
       //
       }
       }
      


      I am now writing JUnit test cases; these objects are not deployed into the Application Server. When I use the same code to lookup java:MySqlDS I receive a NamingException. When I list all bindings, none are found.

      It seems I'm missing something conceptually... based on what I know there should be no difference between objects deployed / outside the Application Server and how they interact with the naming service.

      Thanks in advance.