EJB的不解,高手来拿分 ( 积分: 100 )

  • 主题发起人 主题发起人 neweat
  • 开始时间 开始时间
N

neweat

Unregistered / Unconfirmed
GUEST, unregistred user!
我是jbuild2005+weblogic的环境
开发了一个EntityBean,但在调用时出错
调用方式如下:
Context initial = new InitialContext();
Object objref = initial .lookup("LogInfo");//执行该语句出错
错误信息:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640)
哪位大侠能指点一下?
人气不是很好,还好我已经解决了,分数给自己吧
 
我是jbuild2005+weblogic的环境
开发了一个EntityBean,但在调用时出错
调用方式如下:
Context initial = new InitialContext();
Object objref = initial .lookup("LogInfo");//执行该语句出错
错误信息:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640)
哪位大侠能指点一下?
人气不是很好,还好我已经解决了,分数给自己吧
 
public void initialize() {
long startTime = 0;
if (logging) {
log("Initializing bean access.");
startTime = System.currentTimeMillis();
}
try {
//get naming context
Context context = getInitialContext();
//look up jndi name
Object ref = context.lookup("Test");
//look up jndi name and cast to Home interface
testHome = (TestHome) PortableRemoteObject.narrow(ref, TestHome.class);
if (logging) {
log(
"Succeeded initializing bean access through Home interface.");
long endTime = System.currentTimeMillis();
log("Execution time: " + (endTime - startTime) + " ms.");
}
} catch (Exception e) {
if (logging) {
log("Failed initializing bean access.");
}
e.printStackTrace();
}
}
private Context getInitialContext() throws NamingException {
Hashtable environment = new Hashtable();
environment.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
environment.put(Context.URL_PKG_PREFIXES,
"org.jboss.naming:org.jnp.interfaces");
environment.put(Context.PROVIDER_URL, "jnp://localhost:1099");
return new InitialContext(environment);
}
 
后退
顶部