aspose file tools*
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 Soft Skills this week in the Jobs Discussion 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
Author

problem of accessing EJB through EJBContext.lookup()

Bidyut Majumdar
Greenhorn

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/com.session.target.TargetSessionBeanRemote

Is it possible to do it?

following is my code snippet.

@Stateless
public class SourceSessionBean implements SourceSessionBeanRemote, SourceSessionBeanLocal {


TargetSessionBeanRemote tgtRemote;

@Resource
SessionContext sctx;

/**
* Default constructor.
*/
public SourceSessionBean() {

}


public void sourceMethod() {

tgtRemote = (TargetSessionBeanRemote)
sctx.lookup(TargetSessionBeanRemote.class.getName());
tgtRemote.targetMethod();

}


}


@Stateless
public class TargetSessionBean implements TargetSessionBeanRemote, TargetSessionBeanLocal {

/**
* Default constructor.
*/
public TargetSessionBean() {

}


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

}


}
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9319
    
  17

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: http://aspose.com/file-tools
 
subject: problem of accessing EJB through EJBContext.lookup()