1 Reply Latest reply on Aug 29, 2002 7:40 PM by David Jencks

    Problem - DefaultDS not bound

    Todd G. Nist Newbie

      I have a basic client program which is trying to gain access to the data source for testing. When the below program attempts to access the DefaultDS, the following exception is thrown:

      javax.naming.NameNotFoundException: No object bound for java:/DefaultDS
      at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:116)
      at javax.naming.InitialContext.lookup(InitialContext.java:345)
      at examples.ClientTest.main(ClientTest.java:30)


      The basic program is as follows:

      package examples;

      import javax.naming.*;
      import javax.rmi.PortableRemoteObject;
      import java.util.Hashtable;
      import java.util.Enumeration;
      import javax.sql.DataSource;

      public class ClientTest {

      public static void main(String[] args) {
      try {
      Hashtable props = new Hashtable();

      // set up JBoss JNDI properties

      props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      props.put(Context.PROVIDER_URL, "localhost:1099");
      props.put("java.naming.rmi.secruity.manager", "yes");
      props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming");

      Context ctx = new InitialContext(props);

      for (Enumeration e = ctx.list(ctx.getNameInNamespace()); e.hasMoreElements();) {
      System.out.println(e.nextElement().toString());
      }

      DataSource ds = null;

      ds = (javax.sql.DataSource)ctx.lookup("java:/DefaultDS");
      //Object objref = ctx.lookup("ejb/examples/MyTestSessionBean");

      System.out.println("The DataSource is: " + ds);

      } catch(javax.naming.NamingException ne) {
      System.out.println(ne.getMessage());
      ne.printStackTrace();
      } catch( Exception e) {
      System.out.println(e.getMessage());
      }
      } // ---- main ----
      } // ---- ClientTest ----

      The program generates the following output:

      XAConnectionFactory: org.jboss.mq.SpyXAConnectionFactory
      jmx:Apollo:rmi: org.jboss.jmx.adaptor.rmi.RMIAdaptorImpl
      UserTransactionSessionFactory: org.jboss.tm.usertx.server.UserTransactionSessionFactoryImpl
      RMIXAConnectionFactory: org.jboss.mq.SpyXAConnectionFactory
      topic: org.jnp.interfaces.NamingContext
      queue: org.jnp.interfaces.NamingContext
      ConnectionFactory: org.jboss.mq.SpyConnectionFactory
      RMIConnectionFactory: org.jboss.mq.SpyConnectionFactory
      UserTransaction: org.jboss.tm.usertx.client.ClientUserTransaction
      ejb: org.jnp.interfaces.NamingContext
      invokers: org.jnp.interfaces.NamingContext
      UILXAConnectionFactory: org.jboss.mq.SpyXAConnectionFactory
      UILConnectionFactory: org.jboss.mq.SpyConnectionFactory
      No object bound for java:/DefaultDS
      javax.naming.NameNotFoundException: No object bound for java:/DefaultDS
      at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:116)
      at javax.naming.InitialContext.lookup(InitialContext.java:345)
      at examples.ClientTest.main(ClientTest.java:30)



      I have looked at the JNDIView to ensure that the data source is bound in it is:

      java: Namespace
      +- DefaultDS (class: org.jboss.resource.adapter.jdbc.local.LocalDataSource)
      +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
      +- SecurityProxyFactory (class: org.jboss.security.SubjectSecurityProxyFactory)
      +- DefaultJMSProvider (class: org.jboss.jms.jndi.JBossMQProvider)
      +- CounterService (class: org.jboss.varia.counter.CounterService)
      +- comp (class: javax.naming.Context)
      +- JmsXA (class: org.jboss.resource.adapter.jms.JmsConnectionFactoryImpl)
      +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
      +- jaas (class: javax.naming.Context)
      | +- JmsXARealm (class: org.jboss.security.plugins.SecurityDomainContext)
      | +- jbossmq (class: org.jboss.security.plugins.SecurityDomainContext)
      +- timedCacheFactory (class: javax.naming.Context)
      Failed to lookup: timedCacheFactory, errmsg=org.jboss.util.TimedCachePolicy
      +- TransactionPropagationContextExporter (class: org.jboss.tm.TransactionPropagationContextFactory)
      +- Mail (class: javax.mail.Session)
      +- StdJMSPool (class: org.jboss.jms.asf.StdServerSessionPoolFactory)
      +- TransactionPropagationContextImporter (class: org.jboss.tm.TransactionPropagationContextImporter)
      +- ProgressDS (class: org.jboss.resource.adapter.jdbc.local.LocalDataSource)
      +- TransactionManager (class: org.jboss.tm.TxManager)

      I am sure I am missing something obvious, but I don't see it. Any help is appreciated.

      Regards,

      Todd