1 Reply Latest reply on Sep 12, 2007 2:40 AM by jaikiran

    DataSource look up failed

    lakshmansai

      Hi,

      I have created a dataSource with jndi name KernelDataSource and it successfully bounded in jboss 4.2 version. When i am trying to look up from my client program i am getting name not bound exception. Can any body look at this problem:

      mysql-ds.xml:


      <local-tx-datasource>
      <jndi-name>KernelDataSource</jndi-name>
      <connection-url>jdbc:mysql://localhost:3306/adminconsole</connection-url>
      <driver-class>com.mysql.jdbc.Driver</driver-class>
      <user-name>baloo</user-name>
      baloo
      <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
      <!-- should only be used on drivers after 3.22.1 with "ping" support
      <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
      -->
      <!-- sql to call when connection is created
      <new-connection-sql>some arbitrary sql</new-connection-sql>
      -->
      <!-- sql to call on an existing pooled connection when it is obtained from pool - MySQLValidConnectionChecker is preferred for newer drivers
      <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
      -->

      <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->

      <type-mapping>mySQL</type-mapping>

      </local-tx-datasource>



      Client.java

      Hashtable props = new Hashtable();
      props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      props.put(Context.PROVIDER_URL, "jnp://192.168.7.11:1099");
      props.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces" );

      InitialContext ic = new InitialContext(props);

      //DataSource ds = (DataSource)ic.lookup("KernelDataSource");
      System.out.println("Datasource :" + ic.lookup("java:KernelDataSource"));

      Exception Stack trace:

      javax.naming.NameNotFoundException: java not bound
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
      at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
      at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.ja
      at java.lang.reflect.Method.invoke(Method.java:585)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
      at sun.rmi.transport.Transport$1.run(Transport.java:153)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:595)
      at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall
      at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
      at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
      at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:589)
      at javax.naming.InitialContext.lookup(InitialContext.java:351)
      at Client.main(Client.java:24)