Problem with JNDI look up for datasource in Websphere

Discussions

General J2EE: Problem with JNDI look up for datasource in Websphere

  1. HI
      I am trying to do a jndi look up for datasource from a standalone java client. The code for the same and printstack is as stated below.

    Code
    ***********************
    try
    {
    java.util.Hashtable parms = new java.util.Hashtable();
    parms.put(
     Context.PROVIDER_URL, "IIOP://10.10.50.175:900/" );
    parms.put (Context.INITIAL_CONTEXT_FACTORY, "com.ibm.ejs.ns.jndi.CNInitialContextFactory");
               
    InitialContext ctx = new InitialContext(parms);
            
    DataSource ds = (DataSource)ctx.lookup("sbcdatasource");
    System.out.println("ds ::: " + ds);
    }
    catch(Exception e)
    {
    System.out.println("Exception e " + e.getClass().getName());
    System.out.println("Exception e " + e.getMessage());
    e.printStackTrace();
    }

    Stack trace
    ************************
    Exception e java.lang.ClassCastException
    Exception e com.ibm.ws.naming.util.CacheableReference
    java.lang.ClassCastException: com.ibm.ws.naming.util.CacheableReference at com.metlife.renewal.datasource.RenewalConnection.createConnectionPool(RenewalConnection.java:108)at com.metlife.renewal.batch.BatchProcess.processRunOnce(BatchProcess.java:159)at com.metlife.renewal.batch.BatchProcess.startProcess(BatchProcess.java:73) at com.metlife.renewal.batch.BatchProcess.main(BatchProcess.java:52)


    Have no idea where i am going wrong. can anybody help.


    Regards
    Makarand Parab

    Threaded Messages (1)

  2. Classpath Problem[ Go to top ]

    Solution for the problem. set CLASSPATH for \WebSphere\AppServer\lib\namingclient.jar, \WebSphere\AppServer\lib\cmImpl.jar, \WebSphere\AppServer\lib\j2cImpl.jar, \WebSphere\AppServer\properties
     and Use IBM JDK in \WebSphere\AppServer\java. It is working for me.