• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to lookup a local interface for a session bean?

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

Hello.

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;

@Stateless
@Remote
@Local
public class SessionEJBBean implements SessionEJBLocal, SessionEJB {
...
}

The local interface:

package model;

@Local
public interface SessionEJBLocal {
...
}

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

package model;

@Remote
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(ResponseImpl.java:234)"

Can someone please give me a hand here?
 
pie. tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic