File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes problem of accessing EJB through EJBContext.lookup() 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 » Java » EJB and other Java EE Technologies
Bookmark "problem of accessing EJB through EJBContext.lookup()" Watch "problem of accessing EJB through EJBContext.lookup()" New topic

problem of accessing EJB through EJBContext.lookup()

Bidyut Majumdar

Joined: Aug 13, 2009
Posts: 2
Hi all,

I am facing a problem. Please help me if its possible.

I created two EJB jar (SourceSessionBean.jar, TargetSessionBean.jar) in a single EAR file and deployed in Sun application server.

Now i am trying to access the target session bean in TargetSessionBean.jar from the source session bean in SourceSessionBean.jar. I am getting error Caused by: javax.naming.NameNotFoundException: No object bound to name java:comp/env/

Is it possible to do it?

following is my code snippet.

public class SourceSessionBean implements SourceSessionBeanRemote, SourceSessionBeanLocal {

TargetSessionBeanRemote tgtRemote;

SessionContext sctx;

* Default constructor.
public SourceSessionBean() {


public void sourceMethod() {

tgtRemote = (TargetSessionBeanRemote)



public class TargetSessionBean implements TargetSessionBeanRemote, TargetSessionBeanLocal {

* Default constructor.
public TargetSessionBean() {


public void targetMethod() {
System.out.println("Target method is called....");


Ankit Garg

Joined: Aug 03, 2008
Posts: 9291

Look in here for a comprehensive coverage about this.

Also please Use Code Tags when you post a source code...

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
I agree. Here's the link:
subject: problem of accessing EJB through EJBContext.lookup()
Similar Threads
Help in stateless and stateful beans ( VAJ )
Hello world example using EJB 3
Facing problem running simple ejb 3.0 example using eclipse and jboss
ClassCastException at lookup
Problem in understanding session beans