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....");
}
}