This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 9280
    
  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()
 
Similar Threads
Help in stateless and stateful beans ( VAJ )
ClassCastException at lookup
Problem in understanding session beans
Facing problem running simple ejb 3.0 example using eclipse and jboss
Hello world example using EJB 3