当前位置: 技术问答>java相关
再次求救,客户端调用ejb报错
来源: 互联网 发布时间:2015-01-06
本文导语: 错误如下: javax.naming.NoInitialContextException:Cannot istantiate class:welogic.jndi.WLInitialContextFactory. Root exception is java.lang.ClassNotFoundException:weblogic.jndi.WLInitialContextFactory 函数如下: public static Context getWeblogicInitialC...
错误如下:
javax.naming.NoInitialContextException:Cannot istantiate class:welogic.jndi.WLInitialContextFactory. Root exception is java.lang.ClassNotFoundException:weblogic.jndi.WLInitialContextFactory
函数如下:
public static Context getWeblogicInitialContext()
throws javax.naming.NamingException {
try
{
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
p.put(Context.PROVIDER_URL, "t3://localhost:7001");
return new InitialContext(p);
} catch (NamingException ne) {
System.out.println("We were unable to get a connection to the WebLogic server at ");
System.out.println("Please make sure that the server is running.");
throw ne;
}
}
help!!
javax.naming.NoInitialContextException:Cannot istantiate class:welogic.jndi.WLInitialContextFactory. Root exception is java.lang.ClassNotFoundException:weblogic.jndi.WLInitialContextFactory
函数如下:
public static Context getWeblogicInitialContext()
throws javax.naming.NamingException {
try
{
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
p.put(Context.PROVIDER_URL, "t3://localhost:7001");
return new InitialContext(p);
} catch (NamingException ne) {
System.out.println("We were unable to get a connection to the WebLogic server at ");
System.out.println("Please make sure that the server is running.");
throw ne;
}
}
help!!
|
你在客户端的classpath中有没有加入weblogic ejb package的path?
|
try this one---maybe!!
public static Context getInitialContext()
throws javax.naming.NamingException
{
Properties p=new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.TengahInitialContextFactory");
p.put(Context.PROVIDER_URL, "t3://localhost:7001");
return new InitialContext(p);
} catch (NamingException ne) {
System.out.println("We were unable to get a connection to the WebLogic server at ");
System.out.println("Please make sure that the server is running.");
throw ne;
}
}
public static Context getInitialContext()
throws javax.naming.NamingException
{
Properties p=new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.TengahInitialContextFactory");
p.put(Context.PROVIDER_URL, "t3://localhost:7001");
return new InitialContext(p);
} catch (NamingException ne) {
System.out.println("We were unable to get a connection to the WebLogic server at ");
System.out.println("Please make sure that the server is running.");
throw ne;
}
}
|
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.TengahInitialContextFactory");
p.put(Context.PROVIDER_URL, "t3://localhost:7001");
return new InitialContext(p);
改成
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL,
"t3://localhost:7001");
return new InitialContext(ht);
试试看,祝你成功!
p.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.TengahInitialContextFactory");
p.put(Context.PROVIDER_URL, "t3://localhost:7001");
return new InitialContext(p);
改成
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL,
"t3://localhost:7001");
return new InitialContext(ht);
试试看,祝你成功!
|
你要是本机使用ejb的话,这样也可以:
public static Context getWeblogicInitialContext()
throws javax.naming.NamingException {
try
{
return new InitialContext();
} catch (NamingException ne) {
System.out.println("We were unable to get a connection to the WebLogic server at ");
System.out.println("Please make sure that the server is running.");
throw ne;
}
}
public static Context getWeblogicInitialContext()
throws javax.naming.NamingException {
try
{
return new InitialContext();
} catch (NamingException ne) {
System.out.println("We were unable to get a connection to the WebLogic server at ");
System.out.println("Please make sure that the server is running.");
throw ne;
}
}