刚开始学j2ee,在连接JDNI遇到一个问题,向各位高手请教该怎么办。
环境:jdk1.5 WebLogic920 Eclipse3.1.2 MyEclipse 4.1.1代码:
package testJNDI;import javax.naming.*;
import java.util.Properties;
public class TestJDNI { /**
 * @param args
 */
public static void main(String[] args) {
// TODO Auto-generated method stub
//System.out.println("Hello World !");
Context ctx = null;
Properties p = new Properties();

p.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
p.put(Context.PROVIDER_URL,"t3://localhost:7001");

try{
ctx = new InitialContext(p);
String test = "JNDI Test Example";
ctx.bind("name", test);
String s = (String)ctx.lookup("name");
System.out.println(s);
String str = "welcome to you ";
ctx.rebind("name",str);
s = (String)ctx.lookup("name");
System.out.println(s);
}
catch(NamingException e)
{
System.out.println(e.toString());
}
}}报错:javax.naming.NoInitialContextException: Cannot instantiate class: weblogic.jndi.WLInitialContextFactory [Root exception is java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory]开始在网上找解决方法,说把WebLogic.jar加到classpath中,我加了之后还是一样。