wood burning stoves*
The moose likes Websphere and the fly likes Help with the local interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "Help with the local interface" Watch "Help with the local interface" New topic

Help with the local interface

xin wen
Ranch Hand

Joined: Oct 11, 2002
Posts: 64
Hi, could anyone help me?
I create an EJB(2.0)project, which contains CMP entity beans and session beans. And also I have a java project, I want to access the entity bean. When I do this:
InitialContext initialContext = new InitialContext();
AliasLocalHome aliasLocalHome = (AliasLocalHome)initialContext.lookup("com/ibm/ejb/entity/AliasLocalHome");
it will give me an error:
"com/ibm/ejb/entity/AliasLocalHome" can not be found.
I added a local EJB reference to ejb.xml
and do this:
InitialContext initialContext = new InitialContext();
AliasLocalHome aliasLocalHome = (AliasLocalHome)initialContext.lookup(java:comp/env/ejb/Alias);
it gave me an error:
Message='Name ejb not found in context "java:comp/env".'
[5/7/03 10:47:37:937 EDT] 21fc7586 SystemErr R Stack Trace to immediately follow:
[5/7/03 10:47:37:947 EDT] 21fc7586 SystemErr R javax.naming.NameNotFoundException: Name ejb not found in context "java:comp/env".
Anybody know how to locate a local home interface from a java project?
Thanks a lot!
Kyle Brown
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
Post your EJB-JAR.xml file.

Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
xin wen
Ranch Hand

Joined: Oct 11, 2002
Posts: 64
Thanks Kyle for replying.
I am able to locate the local entity bean interface from the session bean using the local reference, but I tried to call it from a java project(not an EJB), it gave me the Naming Exception error. I wander if the local interface can not be called from anywhere except a Session Bean?
This is my ejb.jar
<--<br /> <?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 id="ejb-jar_ID">
< display-name>LMSEJB</display-name>
< enterprise-beans>
< entity id="ContainerManagedEntity_1052172169203">
< ejb-name>Alias</ejb-name>
< local-home>com.rippe.lms.global.ejb.entity.AliasLocalHome< /local-home>
< local>com.rippe.lms.global.ejb.entity.AliasLocal</local>
< ejb-class>com.rippe.lms.global.ejb.entity.AliasBean</ejb-class>
< persistence-type>Container< /persistence-type>
< prim-key-class>com.rippe.lms.global.ejb.entity.AliasKey< /prim-key-class>
< reentrant>False< /reentrant>
< cmp-version>2.x< /cmp-version>
< abstract-schema-name>Alias</abstract-schema-name>
< cmp-field id="CMPAttribute_1052172169133">
< field-name>firm< /field-name>
< /cmp-field>
< cmp-field id="CMPAttribute_1052172169143">
< field-name>userid< /field-name>
< /cmp-field>
< ejb-local-ref id="EJBLocalRef_1052252823985">
< description></description>
<e jb-ref-name>ejb/Alias</ejb-ref-name>
< ejb-ref-type>Entity</ejb-ref-type>
< local-home>com.rippe.lms.global.ejb.entity.AliasLocalHome< /local-home>
< local>com.rippe.lms.global.ejb.entity.AliasLocal< /local>
< ejb-link>Alias< /ejb-link>
< /ejb-local-ref>
< /entity>
< session id="Access">
< ejb-name>Access< /ejb-name>
< home>com.rippe.lms.global.ejb.session.AccessHome< /home>
< remote>com.rippe.lms.global.ejb.session.Access< /remote>
< ejb-class>com.rippe.lms.global.ejb.session.AccessBean< /ejb-class>
< session-type>Stateless< /session-type>
< transaction-type>Container< /transaction-type>
< ejb-local-ref id="EJBLocalRef_1052406041770">
< description>< /description>
< ejb-ref-name>ejb/Alias< /ejb-ref-name>
< ejb-ref-type>Entity< /ejb-ref-type>
< local-home>com.rippe.lms.global.ejb.entity.AliasLocalHome< /local-home>
< local>com.rippe.lms.global.ejb.entity.AliasLocal< /local>
< ejb-link>Alias< /ejb-link>
< /ejb-local-ref>
< /session>
< /enterprise-beans>
< /ejb-jar>
[ May 08, 2003: Message edited by: xin wen ]
Consider Paul's rocket mass heater.
subject: Help with the local interface
Similar Threads
Local EJB lookup problem
Please help with the local interface
Calling a BMP Entity Bean 2.0 From the Web Module..WSAD 5.1.1
Calling a BMP Entity Bean 2.0 From the Web Module
Connection Pooling and JDBC lookup.