• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem of accessing EJB through EJBContext.lookup()

 
Bidyut Majumdar
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9497
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look in here for a comprehensive coverage about this.

Also please Use Code Tags when you post a source code...
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic