Help coderanch get a
new server
by contributing to the fundraiser
  • 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 ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

How to lookup a local interface for a session bean?

Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I am trying out EJBs for the first time and i ran into a problem trying to lookup the local interface of a session bean.

My session EJB looks like this:

package model;

public class SessionEJBBean implements SessionEJBLocal, SessionEJB {

The local interface:

package model;

public interface SessionEJBLocal {

And my remote interface (that i don't wish to use):

package model;

public interface SessionEJB {

Now i have a simple test client where i would like to use the session bean. I tried this (among a few other ideas that didn't work):

@EJB(name = "model/SessionEJBBean", beanInterface = SessionEJBLocal.class)
public class SessionEJBClient1 {
public static void main(String [] args) {
try {
final Context context = getInitialContext();
Object ref = context.lookup("java:comp/env/model/SessionEJBBean");
SessionEJBLocal sessionEJB = (SessionEJBLocal) ref;

This fails with the error message: "javax.naming.NameNotFoundException: While trying to lookup 'java:comp.env/model/SessionEJBBean' didn't find subcontext 'java:comp'. Resolved '' [Root exception is javax.naming.NameNotFoundException: While trying to lookup 'java:comp.env/model/SessionEJBBean' didn't find subcontext 'java:comp'. Resolved '']; remaining name 'java:comp/env/model/SessionEJBBean'
at weblogic.rjvm.ResponseImpl.unmarshalReturn("

Can someone please give me a hand here?
Brace yourself while corporate america tries to sell us its things. Some day they will chill and use tiny ads.
We need your help - Coderanch server fundraiser
    Bookmark Topic Watch Topic
  • New Topic