6 Replies Latest reply on Oct 11, 2007 12:22 AM by khal houhou

    NameNotFoundException while looking up MySqlDs DataSource

    Kalyan Kumar Newbie

      Hi,
      While looking up MySqlDs datasource I am getting the following exception.
      I have configured everything in mysql-ds.xml and mysql-service.xml. I looked in to jmx-console whether the Datasource JNDI name has been bound and it cleared my doubt that the jndi name has been bound. I still cannot able to lookup the datasource.
      Please help me.
      Thank you very much in advance.

      Here is the client code that I am using to lookup:

      import java.sql.*;
      import javax.sql.*;
      import javax.naming.*;

      public class TestClient {

      public static void main(String args[]) throws Throwable {

      java.util.Properties p = new java.util.Properties();
      p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      p.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
      p.put(Context.PROVIDER_URL, "localhost:1099");
      Context ctx = new javax.naming.InitialContext(p);
      DataSource ds = (DataSource) ctx.lookup("java:/MySqlDS");
      Connection conn = ds.getConnection();
      System.out.println(conn);
      }
      }



      Exception in thread "main" javax.naming.NameNotFoundException: MySqlDS not bound

      at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:503)
      at org.jnp.server.NamingServer.getObject(NamingServer.java:509)
      at org.jnp.server.NamingServer.lookup(NamingServer.java:282)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
      java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
      at sun.rmi.transport.Transport$1.run(Transport.java:148)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
      60)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
      .java:701)
      at java.lang.Thread.run(Thread.java:534)
      at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknow
      n Source)
      at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
      at sun.rmi.server.UnicastRef.invoke(Unknown Source)
      at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:528)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:507)
      at javax.naming.InitialContext.lookup(Unknown Source)
      at TestClient.main(TestClient.java:14)