2 Replies Latest reply on Jul 29, 2005 7:09 AM by darranl

    Outside Container JNDI Access

    rathorev

      How can I access JNDI components from outside the Web/App Server container. (I am able to access the same from a servlet or a JSP running from same or defferent PC)

      My server is running on some PC, I want to write a simple Class with main (String []) method to access the JNDI components from a different PC.

      For example the following code is not able to get the DSN provided in mssql-xa-ds.xml under server/default/deploy folder.


      public class ServiceLocator {

      public static void main(String[] args) {
      InitialContext _initContext = null;
      DataSource _dataSource = null;
      Properties env = new Properties();
      env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      env.setProperty(Context.PROVIDER_URL, "jnp://localhost:1099");
      env.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
      try {
      _initContext = new InitialContext(env);
      System.out.println("Created InitialContext, env=" + env);
      Object obj = _initContext.lookup("java:/SomeDSN");
      } catch (NamingException e) {
      e.printStackTrace();
      }
      }
      }