• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

problem of accessing EJB through EJBContext.lookup()

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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....");

}


}
 
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
To do a great right, do a little wrong - shakepeare. twisted little ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic