can not find jndi name in Weblogic 8.1 sp1 + JB9


2003-10-29 10:28:06 AM
jbuilder21
HI,
Created a very simple session bean using weblogic 8.1 sp1 in JB9.
The session bean's name is Agent. Here is the exception thrown by
lookup : 'javax.naming.NameNotFoundException: Unable to resolve 'Agent'
Resolved ; remaining name 'Agent'
Following is the source code:
Context context = getInitialContext(); //ok, see source code below
Object ref = context.lookup("Agent"); //error, throw the exception
//look up jndi name and cast to Home interface
agentHome = (AgentHome) PortableRemoteObject.narrow(ref,
AgentHome.class);
//////////////////
private Context getInitialContext() throws Exception {
String url = "t3://localhost:7001";
String user = null;
String password = null;
Properties properties = null;
try {
properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
properties.put(Context.PROVIDER_URL, url);
if (user != null) {
properties.put(Context.SECURITY_PRINCIPAL, user);
properties.put(Context.SECURITY_CREDENTIALS, password == null ?
"" : password);
}
return new InitialContext(properties); //successful return
}
catch(Exception e) {
log("Unable to connect to WebLogic server at " + url);
log("Please make sure that the server is running.");
throw e;
}
}
Here is the ejb-jar.xml (part)
<enterprise-beans>
<session>
<display-name>Agent</display-name>
<ejb-name>Agent</ejb-name>
<home>knoweledgedepot.AgentHome</home>
<remote>knoweledgedepot.Agent</remote>
<ejb-class>knoweledgedepot.AgentBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
Here is the web;pgoc-ejb-jar.xml (part)
<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>Agent</ejb-name>
<jndi-name>Agent</jndi-name>
</weblogic-enterprise-bean>
Any hint?
I successful built this example under Borland Enterprise Server. But
Weblogic seems to be a different story.
Thanks.
Danny Wang