This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes JNDI problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JNDI problem" Watch "JNDI problem" New topic
Author

JNDI problem

Jan Tsui
Greenhorn

Joined: Dec 27, 2003
Posts: 2
I am using JBuilder 9 and Weblogic 8.1.
When I run a EJB client, the NameNotFoundException is triggered when it perform context lookup. Please help!
The code is as following:
try {
Context context = getInitialContext();
Object ref = context.lookup("abc");
loginHome = (LoginHome) PortableRemoteObject.narrow(ref, LoginHome.class);
}
catch(Exception e) {
if (logging) {
log("Failed initializing bean access.");
}
e.printStackTrace();
}
}
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);
return new InitialContext(properties);
}
catch(Exception e) {
log("Unable to connect to WebLogic server at " + url);
log("Please make sure that the server is running.");
throw e;
}
The ejb-jar.xml is as following:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<enterprise-beans>
<session>
<display-name>Login</display-name>
<ejb-name>Login</ejb-name>
<home>test.LoginHome</home>
<remote>test.Login</remote>
<ejb-class>test.LoginBean</ejb-class>
<session-type>Stateful</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<description />
<ejb-name>Login</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
The weblogic-ejb-jar.xml is as following:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE weblogic-ejb-jar PUBLIC '-//BEA Systems, Inc.//DTD WebLogic 8.1.0 EJB//EN' 'http://www.bea.com/servers/wls810/dtd/weblogic-ejb-jar.dtd'>
<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>Login</ejb-name>
<jndi-name>abc</jndi-name>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>
Jan Tsui
Greenhorn

Joined: Dec 27, 2003
Posts: 2
I have solved such stupid question.
I haven't deploy the EJB first, I just run the server and client application.
 
 
subject: JNDI problem