/**
* 在JNDI树中寻找EJB主接口
*/
private TraderHome lookupHome() throws NamingException
{
// 使用JNDI寻找EJB
Context ctx = getInitialContext();
try {
Object home = ctx.lookup(JNDI_NAME);
return (TraderHome) narrow(home, TraderHome.class);
} catch (NamingException ne) {
//异常处理
log("The client was unable to lookup the EJBHome. Please make sure ");
log("that you have deployed the ejb with the JNDI name "+JNDI_NAME+" on the WebLogic server at "+url);
throw ne;
}
}
我想是上面的哪个地方有毛病吧。
谁来指正一下。
* 在JNDI树中寻找EJB主接口
*/
private TraderHome lookupHome() throws NamingException
{
// 使用JNDI寻找EJB
Context ctx = getInitialContext();
try {
Object home = ctx.lookup(JNDI_NAME);
return (TraderHome) narrow(home, TraderHome.class);
} catch (NamingException ne) {
//异常处理
log("The client was unable to lookup the EJBHome. Please make sure ");
log("that you have deployed the ejb with the JNDI name "+JNDI_NAME+" on the WebLogic server at "+url);
throw ne;
}
}
我想是上面的哪个地方有毛病吧。
谁来指正一下。
weblogic server 6.1
我是照书做的啊。
你可以现在weblogic server的console控制台上看看这个EJB的状态,
以及看看JNDI树是否正确
1、Context ctx = getInitialContext();
里面注意要把url和factory加进去,你的好像是加了,但是不知道是否正确!
2、检查你在client里定义的jndi名字是否和你deplay ejb里面的配置文件一致!
/**
* 使用属性对象获取JNDI服务上下文
*/
private Context getInitialContext() throws NamingException {
try {
// 声明属性对象
Properties h = new Properties();
h.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
h.put(Context.PROVIDER_URL, url);
//返回的特定属性的上下文对象
return new InitialContext(h);
} catch (NamingException ne) {
//异常处理
log("We were unable to get a connection to the WebLogic server at "+url);
log("Please make sure that the server is running.");
throw ne;
}
}
上面这段代码不就是么。