use InitialContext error

Discussions

EJB programming & troubleshooting: use InitialContext error

  1. use InitialContext error (2 messages)

    I want to use datasource, the code is right in jdk1.3 command line prompt, but it always throw Exception
    (java.lang.NoClassDefFoundError:java.naming.InitialContext)
    in VAJ, java.naming.* is in classpath

    InitialContext ctx = null;
    Properties props = new Properties();
    props.put(javax.naming.Context.PROVIDER_URL, "iiop:///");
    props.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, "com.ibm.ejs.ns.jndi.CNInitialContextFactory");
    try{
    ctx = new InitialContext(props);
    System.out.println("InitialContext");
    DataSource dataSource = (DataSource)ctx.lookup("jdbc/tup");
    Connection jdbcConn = dataSource.getConnection("tup","123");
    }
    catch(Exception e){
    e.printStackTrace();
    }

    I don not know why

    Threaded Messages (2)

  2. use InitialContext error[ Go to top ]

    I think in VAJ you need to start Naming server. Try that and it should work.
  3. use InitialContext error[ Go to top ]

    Do a "check classpath" on your class, then add the "IBM WebSphere Test Environment" and "IBM Enterprise Libraries" projects to your classpath. As "com.ibm.ejs.ns.jndi.CNInitialContextFactory" is a string, VAJ does not identify the reference and does not add the two required projects to your classpath.