Local Interface Lookup in Entity Bean

Can anyone tell me like how to lookup an local Interface of an entity bean in Websphere or WSAD?

LVL 13
Murali MurugesanFull stack Java developerAsked:
Who is Participating?
DarthModConnect With a Mentor Commented:
PAQed with points (50) refunded

Community Support Moderator
Try the following codes.
    InitialContext initContext = new InitialContext();
    EJBLocalHome localHome = (EJBLocalHome) initContext.lookup("java:comp/env/" + jndiHomeName);
    SomeBeanLocal entity = localHome.findByPrimaryKey("1");

The varible 'jndiHomeName' is the ejb reference name created on the session bean.
Refer to redbook http://publib-b.boulder.ibm.com/abstracts/sg246957.html (Chapter 12 Implementing the session facade) on how to create the ejb reference.

You can also refer to the J2EE design pattern http://java.sun.com/blueprints/patterns/ServiceLocator.html for the above codes.

Boon Leng
Murali MurugesanFull stack Java developerAuthor Commented:
I have solved the problem myself.

I had already written the above code.I also created the reference for the bean as boonleng.

The mistake was i didnt create a reference in the web.xml for that local bean.Once i created that my code was working fine.

Thanx for the help.


Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.